what i posted above is the error that i get when i try to invoke JFileChooser.
Am tempted to think that its something to do with windows Look and feel not accepting the way i am using JFileChooser because if i use another LookAndFeel it works properly.
This is how i am doing it
|
Code:
|
final JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File("."));
int returnVal = fc.showOpenDialog(jMenuItem3);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String f =file.getName();
try {
//At this point i read data in the file
......
......
}catch (IOException e) {
e.printStackTrace();
} |
And for the look and feel, this is how i implement it
|
Code:
|
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException ex) {
Logger.getLogger(XenonConcUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(XenonConcUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(XenonConcUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(XenonConcUI.class.getName()).log(Level.SEVERE, null, ex);
}
new XenonConcUI().setVisible(true);
}
});
} |