我需要在 JDK 1.6 中设置 LookAndFeel 文件。 我有两个文件:
napkinlaf-swingset2.jar
餐巾纸.jar
如何设置和使用它?
我想要 GTK 外观或 Qt 外观,它们可用吗?
最佳答案
此页面解释了如何使用 Look&Feels: http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html
你可以通过命令行来实现:
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel MyApp
或者在代码中:
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
您需要确保包含外观的 jar 位于应用程序类路径中。这是如何工作的取决于应用程序。一种典型的方法是将其放在 lib 文件夹中。
JDK 中默认可用的 Look&Feels 是:
com.sun.java.swing.plaf.gtk.GTKLookAndFeel
com.sun.java.swing.plaf.motif.MotifLookAndFeel
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
引用上面的链接:
The GTK+ L&F will only run on UNIX or Linux systems with GTK+ 2.2 or later installed, while the Windows L&F runs only on Windows systems. Like the Java (Metal) L&F, the Motif L&F will run on any platform.
关于java - 如何在 Java 中设置 LookAndFeel 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/145972/