Set the LookAndFeelTag(s): Swing


By default, Swing will use the Metal LookAndFeel. To set the LookAndFeel to the current OS under which the JVM is running, use this snippet :
  try {
    UIManager.setLookAndFeel(
      UIManager.getSystemLookAndFeelClassName());
    } 
  catch (Exception e) { 
    e.printStackTrace();
}

Even with the new naming mecanism in JDK1.2, some LookAndFeel packages are keeping the oldname.

Windowscom.sun.java.swing.plaf.windows (no change)
Motifcom.sun.java.swing.plaf.motif (no change)
Maccom.sun.java.swing.plaf.mac (no change)
Metaljavax.swing.plaf.metal (new)
Basicjavax.swing.plaf.basic (new)
Multijavax.swing.plaf.multi (new)

These packages are located in the rt.jar file.


blog comments powered by Disqus