change look&feel for file chooser
hello,
i am using a 3rd party look&feel in my application.
it looks greate, but the file chooser looks different and not very nice.
i wanne have it look like the file chooser when WindowsLookAndFeel is set.
my question: can i set the windowslookandfeel only for jfilechooser?
thx
lukas
You don't need to do that. You can apply any UI to any component after the default has been implicitly installed during its construction.
eg,
JFileChooser f = new JFileChooser();
f.setUI(new BasicFileChooserUI());
You do have to be careful with other L&Fs, though. For instance the Windows L&F is only available on Windows platforms, so you'd have to do something like the following,
JFileChooser f = new JFileChooser();
FileChooserUI ui = null;
try
{
ui = Class.forName("com.sun.java.swing.plaf.windows.WindowsFileChooserUI").newInstance();
}
catch (Exception e)
{
ui = new BasicFileChooserUI();
}
f.setUI(new BasicFileChooserUI());