NewB ? execute program, after digging...
around and putting on my asbestos suit I must post a NewB ?
Seems silly but I cannot find an example of how to run/execute/spawn a program from a file chooser. I can design the form using manual and netbeans with some understanding. I have looked in many books and online and it seems the last bit of information I need is hidden from me. How to actually accomplish something other than cool things along the way to accomplishing that something.
All I want to do is select a file from a file chooser and submit that file to an external exe to act upon. Sounds simple enough...
Your help will be greatly appreciated.
Thx,
seagee
[664 byte] By [
seageea] at [2007-10-2 21:52:04]

> around and putting on my asbestos suit I must post a
> NewB ?
>
> Seems silly but I cannot find an example of how to
> run/execute/spawn a program from a file chooser. I
> can design the form using manual and netbeans with
> some understanding. I have looked in many books and
> online and it seems the last bit of information I
> need is hidden from me. How to actually accomplish
> something other than cool things along the way to
> accomplishing that something.
>
> All I want to do is select a file from a file
> chooser and submit that file to an external exe to
> act upon. Sounds simple enough...
>
> Your help will be greatly appreciated.
Here's one way:
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
public class ExecTest {
ExecTest() {
JFileChooser jfc = new JFileChooser();
int result = jfc.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File textFile = jfc.getSelectedFile();
try {
Runtime.getRuntime().exec("notepad " + textFile.getAbsolutePath(), null);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
public static void main(String[] args) {
new ExecTest();
}
}
>
> Thx,
> seagee
We are not worthy, we are not worthy!!!
works like a charm, I'll have to play games with platforms but that is a simple (gulp) 1-2-3 thing...
Thank you very much. Odd that I could not find how to get to the bottom line as easily as finding out about all the really cool things java/swing can do. I know it was a stupid ? but it was not like I didn't look around or try to derive my own answer.
Thanks again!
seagee