45

我是 Java 编程新手,想知道是否可以在 Java GUI 应用程序中获得 Windows 原生外观。显然 Swing 是行不通的。

4

3 回答 3

83

使用以下内容:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

阅读UIManager如何设置外观以获取更多信息。

于 2012-07-11T05:24:43.083 回答
16

试试这个....

语法是:

UIManager.setLookAndFeel(PLAF); (Pluggable Look and Feel)

因此,您必须包括以下 3 行。

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

SwingUtilities.updateComponentTreeUI(frame);

updateComponentTreeUI(frame);

SwingUtilities.updateComponentTreeUI(frame)用于在更改后刷新框架。

于 2012-07-11T04:26:49.037 回答
-3

试试这个代码:

javax.swing.UIManager.setLookAndFeel("Windows")
于 2012-07-11T03:31:16.903 回答