我无法弄清楚如何更改我在NetBeans平台框架上构建的应用程序的LookAndFeel,有人可以帮忙吗?我想使用TinyLAF java api http://www.muntjak.de/hans/java/tinylaf/index.html来改变它的外观。我知道在NetBeans IDE中开发常规Swing应用程序时如何更改LookAndFeel,但在NetBeans平台框架上开发它时却不知道。
这是我用于常规Swing应用程序的TinyLAF代码:
Toolkit.getDefaultToolkit().setDynamicLayout(true);
System.setProperty("sun.awt.noerasebackground", "true");
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try {
UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");
} catch(Exception ex) {
ex.printStackTrace();
}
TinyLaF查找名为“Default.theme”的默认主题文件(区分大小写)。如果找到,则在启动时加载该文件。 ('Default.theme'文件是一个普通的TinyLaF .theme文件,只需要一个特殊名称,你可以获取任何.theme文件并将其重命名为'Default.theme')。
TinyLaF将搜索以下网址:
请注意,我的问题不是如何更改NetBeans IDE的LookAndFeel,而是如何为基于NetBeans平台框架构建的Java应用程序执行此操作。
答案 0 :(得分:2)
我发现以下搜索网:您需要在“安装程序”模块中执行此操作。 查看此链接,了解您需要添加的位置:http://joshiegeek.blogspot.co.il/2012/01/netbeans-platform-custom-laf.html
这个有实际的代码示例(请忽略标题:)):http://forums.netbeans.org/topic39450.html
最后这个谈到了一个特定的平台,但在此过程中几乎没有评论:https://blogs.oracle.com/geertjan/entry/blue_look_and_feel_for
答案 1 :(得分:1)
1。您可以根据 MVC架构轻松更改Swing的外观和风格。
2。 Swing也称为PLAF
(可插入的外观),因此保持相同的模型部分并更改视图< / strong>,例如桌面和Web应用程序的相同模型。
3. 使用
UIManager.setLookAndFeel(Your_Choice_of_Look_and_Feel); // To set the Look and Feel
SwingUtilities.updateComponentTreeUI(frame); // To refresh the JFrame and Components
有关详细信息,请参阅此处:
http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
答案 2 :(得分:0)
必须找到早期帖子中提到的关于回程机器的第一个链接...
答案是添加运行时参数或将其放在project.properties文件中。要添加的行(例如Metal)是
run.args.extra=--laf javax.swing.plaf.metal.MetalLookAndFeel