Greyskull
Mar 17th, 2008, 12:18 PM
hello,
the following code is an extract of my code
public FileChooserDemo()
{
fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
//fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
openButton = new JButton("Open a File...");
openButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == openButton) {
int returnVal = fc.showOpenDialog(FileChooserDemo.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
}
The jframe is set-up so that it contains a jtextarea and a jbutton (open file).
How can i get the path of the file(picture - ill expand the code so that it will only select pictures) selected by the user and place the path onto the textarea?
Thanks for any help and/or suggestions,
the following code is an extract of my code
public FileChooserDemo()
{
fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
//fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
openButton = new JButton("Open a File...");
openButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == openButton) {
int returnVal = fc.showOpenDialog(FileChooserDemo.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
}
The jframe is set-up so that it contains a jtextarea and a jbutton (open file).
How can i get the path of the file(picture - ill expand the code so that it will only select pictures) selected by the user and place the path onto the textarea?
Thanks for any help and/or suggestions,