com.quadrique.jbuildingblocks.gui
Class LookAndFeelHandler

java.lang.Object
  extended by com.quadrique.jbuildingblocks.gui.LookAndFeelHandler

public class LookAndFeelHandler
extends Object

LookAndFeel manipulation goodies

Author:
Hervé Rivere

Field Summary
static String KUNSTSTOFF_CLASS_NAME
           
static String METAL_CLASS_NAME
           
static String MOTIF_CLASS_NAME
           
static String SKIN_CLASS_NAME
          constants
static String WINDOWS_CLASS_NAME
           
 
Constructor Summary
LookAndFeelHandler()
          Constructor
 
Method Summary
 void addInstalledLookAndFeel()
          add the installed look and feels (Metal, Motif, Microsoft on a Microsoft platform, Macintosh on a Macintosh platform)
 void addKunststoff()
          use this method to add the kunststoff look and feel to the list of LAF.
 void addSkin(String zName, String zTheme)
          use this method to add a Skin LAF theme Please note that the skinlf.jar file has to be available in the application class path as well as the theme file
 boolean canCurrentLAFBeReplacedOnTheFly()
           
 int getCurrent()
           
 LookAndFeelInfo getInfo(int zPosition)
           
 LookAndFeelInfo getInfo(String zClassName, String zExtensionName)
           
static LookAndFeelHandler getInstance()
          This method returns an instance of the LookAndFeelHandler class.
 int getNbOfLookAndFeel()
           
 int getPosition(String zClassName, String zExtensionName)
           
 void setLookAndFeel(String zLAFClassName, String zLAFExtensionName)
          try to set the look and feel to the given look and feel class and extension name if not found, the default java look and feel is used
 void setLookAndFeelToKunststoff()
          try to set the look and feel to the Kunststoff look and feel if not found, the default java look and feel is used
 void setLookAndFeelToMetal()
          try to set the look and feel to the Metal look and feel if not found, the default java look and feel is used
 void setLookAndFeelToMotif()
          try to set the look and feel to the motif look and feel if not found, the default java look and feel is used
 void setLookAndFeelToWindows()
          try to set the look and feel to the windows look and feel if not found, the default java look and feel is used Please note that due to licensing reasons, the windows look and feel is not available on non-microsoft platforms
 void updateGui(Component zComponent)
          update the component(s) with the current look and feel You would typically call this method after calling setLookAndFeel().
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SKIN_CLASS_NAME

public static final String SKIN_CLASS_NAME
constants

See Also:
Constant Field Values

KUNSTSTOFF_CLASS_NAME

public static final String KUNSTSTOFF_CLASS_NAME
See Also:
Constant Field Values

METAL_CLASS_NAME

public static final String METAL_CLASS_NAME
See Also:
Constant Field Values

MOTIF_CLASS_NAME

public static final String MOTIF_CLASS_NAME
See Also:
Constant Field Values

WINDOWS_CLASS_NAME

public static final String WINDOWS_CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

LookAndFeelHandler

public LookAndFeelHandler()
Constructor

Method Detail

getInstance

public static final LookAndFeelHandler getInstance()
This method returns an instance of the LookAndFeelHandler class. If there has been already one instantiation, the same instance is returned so that it can be shared accross the application. A typical usage would be: LookAndFeelHandler.getInstance().getXxxx() or LookAndFeelHandler lLookAndFeel = LookAndFeelHandler.getInstance();

Returns:
the unique LookAndFeelHandler instance

addInstalledLookAndFeel

public void addInstalledLookAndFeel()
                             throws Exception
add the installed look and feels (Metal, Motif, Microsoft on a Microsoft platform, Macintosh on a Macintosh platform)

Throws:
Exception - if an error occurs

addKunststoff

public void addKunststoff()
                   throws Exception
use this method to add the kunststoff look and feel to the list of LAF. Please note that the kunststoff.jar file has to be available in the application class path

Throws:
Exception - if an error occurs

addSkin

public void addSkin(String zName,
                    String zTheme)
             throws Exception
use this method to add a Skin LAF theme Please note that the skinlf.jar file has to be available in the application class path as well as the theme file

Parameters:
zName - the skin name ( e.g. "Theme Skin")
zTheme - the theme name (e.g. "themepack.zip")
Throws:
Exception - if an error occurs

setLookAndFeel

public void setLookAndFeel(String zLAFClassName,
                           String zLAFExtensionName)
try to set the look and feel to the given look and feel class and extension name if not found, the default java look and feel is used

Parameters:
zLAFClassName - the look and feel class name
zLAFExtensionName - the look and feel extension name (if any)

setLookAndFeelToKunststoff

public void setLookAndFeelToKunststoff()
try to set the look and feel to the Kunststoff look and feel if not found, the default java look and feel is used


setLookAndFeelToWindows

public void setLookAndFeelToWindows()
try to set the look and feel to the windows look and feel if not found, the default java look and feel is used Please note that due to licensing reasons, the windows look and feel is not available on non-microsoft platforms


setLookAndFeelToMetal

public void setLookAndFeelToMetal()
try to set the look and feel to the Metal look and feel if not found, the default java look and feel is used


setLookAndFeelToMotif

public void setLookAndFeelToMotif()
try to set the look and feel to the motif look and feel if not found, the default java look and feel is used


canCurrentLAFBeReplacedOnTheFly

public boolean canCurrentLAFBeReplacedOnTheFly()
                                        throws Exception
Returns:
true if the current look and feel can be changed on the fly
Throws:
Exception - if an error occurs

updateGui

public void updateGui(Component zComponent)
update the component(s) with the current look and feel You would typically call this method after calling setLookAndFeel(). Please note that this method should not be called if the current look and feel cannot be replaced on the fly

Parameters:
zComponent - the top component (all the child components will be updated as well)

getCurrent

public int getCurrent()
Returns:
the position of the current LAF or -1 if it could not be identified

getNbOfLookAndFeel

public int getNbOfLookAndFeel()
Returns:
the number of available look and feels

getInfo

public LookAndFeelInfo getInfo(int zPosition)
                        throws Exception
Parameters:
zPosition - from 0 to getNbOfLookAndFeel()-1
Returns:
the look and feel info associated to the given position
Throws:
Exception - if an error occurs

getInfo

public LookAndFeelInfo getInfo(String zClassName,
                               String zExtensionName)
                        throws Exception
Parameters:
zClassName - the corresponding class name
zExtensionName - the extension name (if any, mainly used for skin look and feel)
Returns:
the look and feel info associated to the given class and extension name null if none is found
Throws:
Exception - if an error occurs

getPosition

public int getPosition(String zClassName,
                       String zExtensionName)
                throws Exception
Parameters:
zClassName - the corresponding class name
zExtensionName - the extension name (if any, mainly used for skin look and feel)
Returns:
the position of the look and feel associated to the given class and extension name -1 if none is found
Throws:
Exception - if an error occurs


Copyright © 2001-2009 Quadrique Corporation. All Rights Reserved.