我正在尝试生成具有Windows外观的JFileChooser
。 我找不到更改它的方法,因此我创建了一个扩展JFileChooser
的基类,并使用以下代码更改其UI:
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()); }
然后,在另一个类中,我调用
FileChooser chooser = new FileChooser(fileName);
int val = chooser.showOpenDialog(null);
但弹出的对话框具有Java的外观和感觉。 有什么想法可以改变这种情况吗?JFileChooser类中是否有我可以使用而不是使用这个扩展类的方法?
谢谢!