I'm trying to generate a JFileChooser
that has the Windows look-and-feel. I couldn't find a method to change it, so I created a base class that extends JFileChooser
that changes the UI with the following code:
public FileChooser(){
this(null);
}
public FileChooser(String path){
super(path);
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) { System.err.println("Error: " + e.getMessage()); }
Then, in another class, I call
FileChooser chooser = new FileChooser(fileName);
int val = chooser.showOpenDialog(null);
but the dialog box that comes up has the Java look and feel. Any thoughts on how to change this? Is there a method of the JFileChooser class that I can use instead of this extended class?
Thank you!
If you don't need to change the Look and Feel, could you try putting the UIManager.setLookAndFeel(..) line in the main method of your entry class?
That seems to work for me, though I am at a loss as to why it won't work the way you have set it upt.