[英]How to change the theme of a Java application in Netbeans?
I want to change the look of a Java application. 我想更改Java应用程序的外观。 I'm just using Netbeans and I don't like the look of metal in it, Instead I want to change it to the Windows look.
我只是在使用Netbeans,我不喜欢其中的金属外观,而是想将其更改为Windows外观。 Is there any way to do it?
有什么办法吗?
I want to make it look like this. 我要使它看起来像这样。
But instead, when I run it, this is what the default look or theme of it is. 但是,当我运行它时,这就是它的默认外观或主题。
Is there any steps to change the default look of it? 是否有任何步骤可以更改其默认外观?
Basically: 基本上:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Will set the Look and feel to the one that your Operating System uses. 将外观设置为您的操作系统使用的外观。
Take a look at this java tutorial which also lists the available themes and how to apply them. 看一下这个Java教程 ,它还列出了可用的主题以及如何应用它们。
Try this : 尝试这个 :
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Metal".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(YourJavaApplicationName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(YourJavaApplicationName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(YourJavaApplicationName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(YourJavaApplicationName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.