Click to See Complete Forum and Search --> : File Chooser
daileyps
September 12th, 2000, 01:12 PM
I have gotten a file chooser working to default to the current directory of a path loaded into a text box from a .mdb, and allow selection/update of that file/path to a new one selected from my file chooser. Now what I want to do is add a button to open the file at the selected path...how do I invoke this? In windows, it would be a shell command, having trouble tracking down doc/syntax for this in java. Assuming user default for program associated with file extension.
Thank you :-)
poochi
September 12th, 2000, 08:49 PM
I assumes that you are using JFileChooser class.
> what I want to do is add a button to open the file at the selected path
By default , if it's a Open dialog , you will get two buttons. 1. Open 2. Cancel.
the showXXXDialog() of JFileChooser returns int. If it's APPROVE_OPTION then you can
get selection file path using getSelectedFile() method.
Here is a sample
JFileChooser fileChooser = new JFileChooser();
int nSelection = fileChooser.showOpenDialog( frame );
if( nSelection == fileChooser.APPROVE_OPTION ){
File selectedFile = fileChooser.getSelectedFile();
}
Poochi...
daileyps
September 13th, 2000, 10:35 AM
Yes, that far I have gotten...what I would like to do with the file path is actually launch the application associated with it to open it. For example, if it is a .txt file, I would like to launch notepad or wordpad, whichever is associated with it and have the document open up in there. If a .doc file, lauch word, if an .exe, etc. etc.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.