OK, something like this should give you the path to the file in 'newSource'
Code:
String newSource = "";
final JFileChooser sourceChooser = new JFileChooser();
int returnValue = sourceChooser.showOpenDialog(caller);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File sourceFile = sourceChooser.getSelectedFile();
newSource=sourceFile.getAbsolutePath();
}
'caller' is the JButton which launced the ActionEvent.
Things get a bit interesting after that. If there are any spaces in the file's path, you'll have problems if you just do
Code:
runEnviron.exec("/usr/bin/myOtherProgram" + newSource);
because Java will parse the string according to spaces and pass each chunk of the file path as a separate argument. You should add each argument as a separate string into an array of strings to be sure it'll work with paths with spaces, e.g.
Code:
String[] command = {"/usr/bin/myOtherProgram", newSource};
Process burnProcess = runEnviron.exec(command);
I hope that makes sense. Hit me back if it doesn't.
Also, Sun has some excellent documentation online:
http://java.sun.com/j2se/1.5.0/docs/api/
Dave