System.out.println (e.getActionCommand());
if(e.getSource() == open) {
// Display the file chooser.
int retval = chooser.showDialog(this, null);
// Get the file name (if the return value is correct)...
if(retval == JFileChooser.APPROVE_OPTION) {
// Retrieve the file name and make sure it isn't null.
File theFile = chooser.getSelectedFile();
if(theFile != null) {
if(theFile.isDirectory()) {
JOptionPane.showMessageDialog(this, "You chose this directory: " +
chooser.getSelectedFile().getAbsolutePath());
} else {
JOptionPane.showMessageDialog(this, "You chose this file: " +
chooser.getSelectedFile().getAbsolutePath());
}
return;
}
}
JOptionPane.showMessageDialog(this, "No file was chosen.");
}