如何在 Netbeans 中更改 Java 应用程序的主题?
How to change the theme of a Java application in Netbeans?
我想更改 Java 应用程序的外观。我只是在使用 Netbeans,我不喜欢它的金属外观,相反我想将它更改为 Windows 外观。有什么办法吗?
我想让它看起来像这样。
但是,当我 运行 它时,这就是它的默认外观或主题。
是否有更改默认外观的步骤?
基本上:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
会将外观设置为您的操作系统使用的外观。
查看 this java tutorial,其中还列出了可用的主题以及如何应用它们。
试试这个:
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);
}
我想更改 Java 应用程序的外观。我只是在使用 Netbeans,我不喜欢它的金属外观,相反我想将它更改为 Windows 外观。有什么办法吗?
我想让它看起来像这样。
但是,当我 运行 它时,这就是它的默认外观或主题。
是否有更改默认外观的步骤?
基本上:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
会将外观设置为您的操作系统使用的外观。
查看 this java tutorial,其中还列出了可用的主题以及如何应用它们。
试试这个:
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);
}