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

5

18

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?

Scuff answered 7/7, 2011 at 8:38 Comment(1)
Try this: Go to inpector view. Right click on your jFrame. Then in preview design select a L&F.Mortician
E
15

The only thing I can find is:

Inspector > Right click on your JFrame > Preview Design

enter image description here

Embrocation answered 7/7, 2011 at 8:55 Comment(2)
@mKorbel: Sorry, I don't understand what you are trying to say :( However, thanks for the +1Embrocation
Thanks! Didn't find it by myselfScuff
L
8

Write this in your main:

try { 
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); 
} catch (Exception ex) { 
    ex.printStackTrace(); 
}
Liberati answered 28/4, 2012 at 5:9 Comment(2)
what are the other values that can be set to setLookAndFeel method??Bifurcate
The other values are: Windows - com.sun.java.swing.plaf.windows.WindowsLookAndFeel Metal - javax.swing.plaf.metal.MetalLookAndFeel GTK - com.sun.java.swing.plaf.gtk.GTKLookAndFeel Nimbus - - Not available as default L&F, in development. It is our implementation of Nimbus GTK theme, which is the default theme for OpenSolaris. Aqua - apple.laf.AquaLookAndFeel Ref# : wiki.netbeans.org/NBLookAndFeelsClaar
C
6

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

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);
}
Calendra answered 28/4, 2015 at 23:4 Comment(0)
I
5

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_options setting:

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

(substituting TinyLAF for wahtever LAF you are using)

Intermingle answered 15/8, 2011 at 21:9 Comment(0)
F
1

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

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

Fenderson answered 10/2, 2014 at 18:59 Comment(1)
That only changes the IDE. Not the JFrame. Netbeans IDE is set to Windows by default, and the JFrame is set to Nimbus.Parfait

© 2022 - 2024 — McMap. All rights reserved.