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?

Roland Schneider
  • 3,615
  • 3
  • 32
  • 43

5 Answers5

15

The only thing I can find is:

Inspector > Right click on your JFrame > Preview Design

enter image description here

Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
8

Write this in your main:

try { 
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); 
} catch (Exception ex) { 
    ex.printStackTrace(); 
}
MH.
  • 45,303
  • 10
  • 103
  • 116
user1362394
  • 89
  • 1
  • 1
  • what are the other values that can be set to setLookAndFeel method?? – stallion Sep 25 '12 at 06:12
  • 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# : http://wiki.netbeans.org/NBLookAndFeels – Chris Sim Dec 04 '14 at 10:36
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);
}
Miss Chanandler Bong
  • 4,081
  • 10
  • 26
  • 36
loverBoy
  • 125
  • 2
  • 13
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)

Sam
  • 3,659
  • 3
  • 36
  • 49
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.

geo
  • 517
  • 1
  • 9
  • 28