Obtain file path and file name using file chooser
- From: "bH" <bherbst65@xxxxxxxxxxx>
- Date: 27 Nov 2006 19:53:25 -0800
Hi All,
I want to obtain both file "path" and the filenamed MyText.txt ....as
in "C:\Documents
and Settings\bH\Desktop\MyShowWithFrame\MyText.txt"
I have tried to discover the options shown in How to Use File Choosers
(The Java™ Tutorials Creating a GUI with JFC-Swing Using Swing
Components).htm
I cannot understand what options should be shown as but this does not
work.
Program snip:
JButton opnButton = new JButton("Open a Text File...");
buttonPanel.add(opnButton);
opnButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = fc.showOpenDialog(FileChooserDemo.this);
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile ();
strngFileName = file.getName();
}
}
});
});
TIA
bH
.
- Follow-Ups:
- Re: Obtain file path and file name using file chooser
- From: Andrew Thompson
- Re: Obtain file path and file name using file chooser
- Prev by Date: Re: about reading of properties file
- Next by Date: Re: Obtain file path and file name using file chooser
- Previous by thread: Javazoom MP3SPI JDK version problem
- Next by thread: Re: Obtain file path and file name using file chooser
- Index(es):