/**
* Demonstrate the JFileChooser.
*/
private void testFileChooser() {
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("A File Chooser");
chooser.setForeground(Color.white);
chooser.setBackground(Color.blue);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
// Uncomment this section of code to apply a FileFilter that masks out
// all
// files whose names do not end with ".java".
// /* Construct an anonymous inner class that extends the abstract
// * FileFilter class.
// */
// charvax.swing.filechooser.FileFilter filter =
// new charvax.swing.filechooser.FileFilter() {
// public boolean accept(File file_) {
// String pathname = file_.getAbsolutePath();
// return (pathname.endsWith(".java"));
// }
// };
// chooser.setFileFilter(filter);
if (chooser.showDialog(this, "Open File") == JFileChooser.APPROVE_OPTION) {
String msgs[] = { "The selected file was:",
chooser.getSelectedFile().getAbsolutePath()};
JOptionPane.showMessageDialog(this, msgs,
"Results of JFileChooser", JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(this,
"The CANCEL button was selected",