ProgramixGenericLib v5.0.1

com.programix.gui.plaf
Class LookAndFeelChanger

java.lang.Object
  extended by com.programix.gui.plaf.LookAndFeelChanger

public class LookAndFeelChanger
extends Object

Used to cycle through a set of look and feels using a keystroke.

The methods (and constructors) of this class can be called by any thread (not just by the event thread).

Author:
Paul Hyde

Nested Class Summary
static class LookAndFeelChanger.LookAndFeelView
           
 class LookAndFeelChanger.MetalView
          An implementation of LookAndFeelChanger.View that is useful for times when all that needs to change is the MetalTheme of the MetalLookAndFeel.
static interface LookAndFeelChanger.View
          Used to define a generic wrapper for a look and feel change.
 
Constructor Summary
LookAndFeelChanger()
          Creates a changes that is not bound to any component.
LookAndFeelChanger(JComponent bindTo)
          Creates a changer bound to the specified component that advanced the view when F12 is pressed.
LookAndFeelChanger(JComponent bindTo, String keyStroke)
          Creates a new changer and binds it to the specified component and listens for the specified keystroke.
 
Method Summary
 void addMetalThemeView(String themeClassName, String themeDisplayName)
          Creates a LookAndFeelChanger.MetalView for the specified theme class.
 void addStandardMetalViews()
          Creates and adds a set of standard Metal themes.
 boolean addSystemView()
          Adds the view for the default system look and feel to the set of views.
 void bind(JComponent bindTo, String keyStroke)
           
static LookAndFeelChanger createStandard(JComponent bindTo, String keyStroke)
          Creates a standard changer, add all the standard metal views, and shows the first view.
 LookAndFeelChanger.View getSystemView()
          Gets the LookAndFeelChanger.View for the default system look and feel.
static boolean isMetalThemeAvailable(String metalThemeClassName)
          Returns true if the specified class is available.
 void showFirstLook()
           
 void showNextLook()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookAndFeelChanger

public LookAndFeelChanger(JComponent bindTo,
                          String keyStroke)
Creates a new changer and binds it to the specified component and listens for the specified keystroke.

Parameters:
bindTo - component to bind to, if null, no keystroke assigned.
keyStroke - the keystroke to listen for to show the next view.

LookAndFeelChanger

public LookAndFeelChanger(JComponent bindTo)
Creates a changer bound to the specified component that advanced the view when F12 is pressed.


LookAndFeelChanger

public LookAndFeelChanger()
Creates a changes that is not bound to any component.

Method Detail

createStandard

public static LookAndFeelChanger createStandard(JComponent bindTo,
                                                String keyStroke)
Creates a standard changer, add all the standard metal views, and shows the first view.


bind

public void bind(JComponent bindTo,
                 String keyStroke)

showFirstLook

public void showFirstLook()

showNextLook

public void showNextLook()

addStandardMetalViews

public void addStandardMetalViews()
Creates and adds a set of standard Metal themes.


isMetalThemeAvailable

public static boolean isMetalThemeAvailable(String metalThemeClassName)
Returns true if the specified class is available. Specifically, the class can be found and loaded, it can be instantiated with a public zero-arg constructor, and it is a subclass of MetalTheme.


addMetalThemeView

public void addMetalThemeView(String themeClassName,
                              String themeDisplayName)
Creates a LookAndFeelChanger.MetalView for the specified theme class. The view is added to the list of views. If the view can not be created (likely because the Metal theme class does not exist on this machine) null is returned.

Parameters:
themeClassName - classname of a subclass of MetalTheme.
themeDisplayName - user appropriate name for display

getSystemView

public LookAndFeelChanger.View getSystemView()
                                      throws UnsupportedLookAndFeelException,
                                             IllegalStateException
Gets the LookAndFeelChanger.View for the default system look and feel. If there are any problems locating and creating the default system look and feel, an exception is thrown.

NOTE: This method must be called by the event handling thread (or else an exception is thrown).

Throws:
UnsupportedLookAndFeelException - if the default system look and feel is unavailable.
IllegalStateException - if not called by the event handling thread.

addSystemView

public boolean addSystemView()
Adds the view for the default system look and feel to the set of views.

NOTE: This method must be called by the event handling thread (or else an exception is thrown).

Returns:
true if the view was created and added, false if the view could not be created.
Throws:
IllegalStateException - if not called by the event handling thread.

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.