Java 如何在 NetBeans GUI Designer Preview 中更改外观?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6607906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 08:11:25  来源:igfitidea点击:

How to change the look and feel in NetBeans GUI Designer Preview?

javaswingnetbeansgui-builder

提问by Roland Schneider

When using the NetBeans GUI Builder the "Preview Design" feature shows the panel with the system look and feel (e.g. Windows). Now I want to preview my panel with a different LaF to get all the gaps and spaces right. Is there a way to tell the gui builder to display the panel with a different LaF?

使用 NetBeans GUI Builder 时,“预览设计”功能会显示具有系统外观和感觉的面板(例如 Windows)。现在我想用不同的 LaF 预览我的面板,以获得正确的所有间隙和空间。有没有办法告诉 gui builder 用不同的 LaF 显示面板?

采纳答案by Martijn Courteaux

The only thing I can find is:

我唯一能找到的是:

Inspector> Right click on your JFrame> Preview Design

Inspector> Right click on your JFrame>Preview Design

enter image description here

在此处输入图片说明

回答by Sam

You can edit the look of the whole designer if you like...

如果您愿意,您可以编辑整个设计师的外观...

In <netbeans_home>/etc/netbeans.conf, append the following to the netbeans_default_optionssetting:

在 中<netbeans_home>/etc/netbeans.conf,将以下内容附加到netbeans_default_options设置中:

--laf de.muntjak.tinylookandfeel.TinyLookAndFeel --cp:p path\to\tinylaf.jar"

(substituting TinyLAF for wahtever LAF you are using)

(用 TinyLAF 代替您正在使用的 Wahtever LAF)

回答by user1362394

Write this in your main:

把这个写在你的主要内容中:

try { 
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); 
} catch (Exception ex) { 
    ex.printStackTrace(); 
}

回答by geo

You can change the of the preview by: Tools-Options Miscellaneous tab Windows tab Look and Feel:Preferred look and feel.

您可以通过以下方式更改预览: 工具-选项 其他选项卡 Windows 选项卡 外观:首选外观。

With this the look and feel of the IDE changes too.

有了这个,IDE 的外观和感觉也发生了变化。

回答by loverBoy

change LaF using preview design will not change the look. it only going to show you how the look is but if you want to change it you have to go to source then look for this code if you did not find it click on + symbol and change the word Windows to what ever you like note:you have to change it for all the jframes to work well

使用预览设计更改 LaF 不会改变外观。它只会向您展示外观,但是如果您想更改它,您必须转到源代码然后查找此代码,如果您没有找到它,请单击 + 符号并将 Windows 一词更改为您喜欢的任何内容 注意:您必须更改它才能使所有 jframe 正常工作

try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
            javax.swing.UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}