目前我的应用程序是使用JFileChooser编写的,但我更喜欢选择文件时的FileDialog外观。有没有改变JFileChooser for Mac OS X的外观和感觉,使它看起来像FileDialog?
答案 0 :(得分:-1)
您可以使用UIManager和Swing Utilities更改某些对象的外观,甚至还可以恢复原始外观。
import javax.swing.plaf. *;
import javax.swing.*;
public class TestClass {
public static void main(String[] args) {
JFrame Frame = new JFrame();
JFileChooser file = new JFileChooser();
LookAndFeel Revert = UIManager.getLookAndFeel();
LookAndFeel LF = UIManager.getSystemLookAndFeelClassName(); // Mac OS
try{
UIManager.setLookAndFeel(LF);
SwingUtilities.updateComponentTreeUI(file); // Changes file to current look and feel
UIManager.setLookAndFeel(Revert); // Remove this is you don't want to revert.
}
catch (Exception Fail) {
System.out.println(Fail);
}
}
}