我想要 JButton 的外观:
我尝试通过这种方式更改 Windows 的外观:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
但显示为:
提前致谢!
最佳答案
将评论序列带到一个独立的答案:
// sets the look and feel to be that of the operating system's
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException |
InstantiationException |
IllegalAccessException |
UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
我给 kiheru 投了赞成票,但看来你设置的时间不对。 您需要在显示组件之前运行此代码 - 我通常将其插入到启动应用程序的原始 run() 方法中,尽管如果我包含闪屏,情况会有所不同。
此外,将来(尤其在谈论 GUI 代码时,这可能会变得可怕)如果您发布可运行的代码示例,人们会更喜欢它,这样我们就可以准确地看到您可能在哪里出错: )
关于java - JButton Windows 外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27486281/