how-to

Others

How to set look and feel to default

For this section you need to use:

import javax.swing.*;

When look and feel is uninitialized, you can call this code for setting default look and feel to default system look and feel (for example from main() function).

try {
  UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch ( ClassNotFoundException ex ) {
  Logger.getLogger( Main.class.getName()).log(Level.SEVERE, null, ex );
} catch ( InstantiationException ex ) {
  Logger.getLogger( Main.class.getName()).log(Level.SEVERE, null, ex );
} catch ( IllegalAccessException ex ) {
  Logger.getLogger( Main.class.getName()).log(Level.SEVERE, null, ex );
} catch ( UnsupportedLookAndFeelException ex ) {
  Logger.getLogger( Main.class.getName()).log(Level.SEVERE, null, ex );
}

When you are on Windows, you will have Windows look and feel.

The exception of this is the case, when is set system property swing.systemlaf - that can define used default look and feel.

For setting swing.systemlaf use this code:

System.setProperty( "swing.systemlaf", "javax.swing.plaf.nimbus.NimbusLookAndFeel" );
, or you can change it permanently.