View RSS Feed

Java Swing

The 'default' look and feel

Rate this Entry
by , 04-26-2012 at 08:41 PM (724 Views)
Methods are provided by UIManager to set or get the current, default Look & feel.
Java Code:
   
public static LookAndFeel 
      getLookAndFeel()

   public static void
      setLookAndFeel(LookAndFeel newLookAndFeel)
      
   public static void 
      setLookAndFeel(String className)
Being default look & feel, cross platformed look and feel of Java which is called “Metal” is initialized by the Swing. But if default look & feel needs to be set by the Swing program explicitly, then this could be done by UIManager.setLookAndFeel() method. For instance, given sample of code sets the default Look & Feel, to be Motif/CDE:
Java Code:
UIManager.setLookAndFeel(
   "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
Following static method is provided by UIManager to obtain the proper LookAndFeel classnames programmatically for these case:
Java Code:
  public static String
     getSystemLookAndFeelClassName()
  public static String 
     getCrossPlatformLookAndFeelClassName()
To make it sure that always program run in the system of platform look & feel, code shall be:
Java Code:
UIManager.setLookAndFeel(
   UIManager.getSystemLookAndFeelClassName());

Submit "The 'default' look and feel" to Facebook Submit "The 'default' look and feel" to Digg Submit "The 'default' look and feel" to del.icio.us Submit "The 'default' look and feel" to StumbleUpon Submit "The 'default' look and feel" to Google

Comments