TopBlend: Here is the first difference. There are 49 differences. is old. is new.


javax.swing.plaf.basic
Class BasicLookAndFeel


java.lang.Object
  extended by javax.swing.LookAndFeel
      extended by javax.swing.plaf.basic.BasicLookAndFeel
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MetalLookAndFeel , SynthLookAndFeel

public abstract class BasicLookAndFeel
extends LookAndFeel
implements Serializable

A base class to use in creating a look and feel for Swing. Implements the a standard base LookAndFeel class from which standard desktop LookAndFeel classes (JLF, Mac, Windows, etc.) can be derived. This class cannot be instantiated directly, however the UI classes "Basic" defines can be.

Each of the ComponentUIs provided by BasicLookAndFeel derives its behavior from the defaults table. Unless otherwise noted each of the ComponentUI implementations in this package document the set of defaults they use. Unless otherwise noted the defaults are installed at the time installUI is invoked, and follow the recommendations outlined in LookAndFeel for installing defaults.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans TM has been added to the java.beans package. Please see XMLEncoder .


Constructor Summary
BasicLookAndFeel ()
           
 
Method Summary
protected   Action createAudioAction ( Object
          Creates and returns           Returns an Action used to play a sound. Action.
protected   ActionMap getAudioActionMap ()
          Returns an ActionMap containing the audio actions for this look and feel. ActionMap.
  UIDefaults getDefaults ()
          Returns           This method is called once by UIManager.setLookAndFeel to create the look and feel defaults. specific defaults table.
protected  void initClassDefaults ( UIDefaults
          Populates table with mappings from           Initialize the uiClassID to the fully qualified name of the ui class. BasicComponentUI mapping.
protected  void initComponentDefaults ( UIDefaults
          Populates table with the defaults for the basic look and feel.            
 void initialize ()
          Initializes           UIManager.setLookAndFeel calls this method before the look and feel. first call (and typically the only call) to getDefaults().
protected  void initSystemColorDefaults ( UIDefaults
          Populates table with system colors.           Load the SystemColors into the defaults table.
protected  void loadSystemColors ( UIDefaults  table, String
          Populates table with           If this is the name-color pairs in systemColors. native look and feel the initial values for the system color properties are the same as the SystemColor constants.
protected  void playSound ( Action
          If necessary, invokes           Decides whether to fire the Action that is passed into it and, if needed, fires the Action's actionPerformed on audioAction to play a sound. method.
 void uninitialize ()
          Uninitializes the           UIManager.setLookAndFeel calls this method just before we're replaced by a new default look and feel.
 
Methods inherited from class javax.swing. LookAndFeel
getDescription , getDesktopPropertyValue , getDisabledIcon , getDisabledSelectedIcon , getID , getLayoutStyle , getName , getSupportsWindowDecorations , installBorder , installColors , installColorsAndFont , installProperty , isNativeLookAndFeel , isSupportedLookAndFeel , loadKeyBindings , makeComponentInputMap , makeIcon , makeInputMap , makeKeyBindings , provideErrorFeedback , toString , uninstallBorder
 
Methods inherited from class java.lang. Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait
 

Constructor Detail

BasicLookAndFeel


public BasicLookAndFeel()
Method Detail

getDefaults


public UIDefaults getDefaults()
Returns the look and feel defaults. The returned UIDefaults is populated by invoking, in order, initClassDefaults, initSystemColorDefaults and initComponentDefaults. Description copied from class: LookAndFeel
This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table. Other applications, for example an application builder, may also call this method.

While this method is public, it should only be invoked by the UIManager when the look and feel is set as the current look and feel and after initialize has been invoked.

Overrides:
getDefaults in class LookAndFeel
Returns:
the look and feel defaults
See Also:
initClassDefaults(javax.swing.UIDefaults) LookAndFeel.initialize() , initSystemColorDefaults(javax.swing.UIDefaults) LookAndFeel.uninitialize() , initComponentDefaults(javax.swing.UIDefaults) UIManager.setLookAndFeel(javax.swing.LookAndFeel)

initialize


public void initialize()
Initializes the look and feel. While this method is public, it should only be invoked by the UIManager when a look and feel is installed as the current look and feel. This method is invoked before the UIManager invokes getDefaults. This method is intended to perform any initialization for the look and feel. Subclasses should do any one-time setup they need here, rather than in a static initializer, because look and feel class objects may be loaded just to discover that isSupportedLookAndFeel() returns false. UIManager.setLookAndFeel calls this method before the first call (and typically the only call) to getDefaults().

Overrides:
initialize in class LookAndFeel
See Also:
LookAndFeel.uninitialize() , UIManager.setLookAndFeel(javax.swing.LookAndFeel)

uninitialize


public void uninitialize()
Uninitializes the look and feel. While this method is public, it should only be invoked by the UIManager when the look and feel is uninstalled. For example, UIManager.setLookAndFeel invokes this when the look and feel is changed. UIManager.setLookAndFeel calls this method just before we're replaced by a new default look and feel.

Subclasses may choose to free up some resources here.

Overrides:
uninitialize in class LookAndFeel
See Also:
LookAndFeel.initialize() , UIManager.setLookAndFeel(javax.swing.LookAndFeel)

initClassDefaults


protected void initClassDefaults(UIDefaults table)
Populates table with mappings from uiClassID to the fully qualified name of the ui class. The value for a particular uiClassID is "javax.swing.plaf.basic.Basic + uiClassID". For example, the value for the uiClassID TreeUI is "javax.swing.plaf.basic.BasicTreeUI". Initialize the uiClassID to BasicComponentUI mapping. The JComponent classes define their own uiClassID constants (see AbstractComponent.getUIClassID). This table must map those constants to a BasicComponentUI class of the appropriate type.

Parameters:
table - the UIDefaults instance the entries are added to
Throws:
NullPointerException - if table is null
See Also:
LookAndFeel getDefaults() , getDefaults()

initSystemColorDefaults


protected void initSystemColorDefaults(UIDefaults table)
Populates table with system colors. This creates an array of name-color pairs and invokes loadSystemColors. Load the SystemColors into the defaults table. The keys for SystemColor defaults are the same as the names of the public fields in SystemColor. If the table is being created on a native Windows platform we use the SystemColor values, otherwise we create color objects whose values match the defaults Windows95 colors.

The name is a String that corresponds to the name of one of the static SystemColor fields in the SystemColor class. A name-color pair is created for every such SystemColor field.

The color corresponds to a hex String as understood by Color.decode. For example, one of the name-color pairs is "desktop"-"#005C5C". This corresponds to the SystemColor field desktop, with a color value of new Color(0x005C5C).

The following shows two of the name-color pairs:


 String[] nameColorPairs = new String[] {
 "desktop", "#005C5C",
 "activeCaption", "#000080" };
 loadSystemColors(table, nameColorPairs, isNativeLookAndFeel());
 
As previously stated, this invokes loadSystemColors with the supplied table and name-color pair array. The last argument to loadSystemColors indicates whether the value of the field in SystemColor should be used. This method passes the value of isNativeLookAndFeel() as the last argument to loadSystemColors.

Parameters:
table - the UIDefaults object the values are added to
Throws:
NullPointerException - if table is null
See Also:
SystemColor , getDefaults() , loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)

loadSystemColors


protected void loadSystemColors(UIDefaults table,
                                String[] systemColors,
                                boolean useNative)
Populates table with the name-color pairs in systemColors. Refer to initSystemColorDefaults(UIDefaults) for details on the format of systemColors. If this is the native look and feel the initial values for the system color properties are the same as the SystemColor constants. If not we use the integer color values in the systemColors argument.

An entry is added to table for each of the name-color pairs in systemColors. The entry key is the name of the name-color pair.

The value of the entry corresponds to the color of the name-color pair. The value of the entry is calculated in one of two ways. With either approach the value is always a ColorUIResource.

If useNative is false, the color is created by using Color.decode to convert the String into a Color. If decode can not convert the String into a Color (NumberFormatException is thrown) then a ColorUIResource of black is used.

If useNative is true, the color is the value of the field in SystemColor with the same name as the name of the name-color pair. If the field is not valid, a ColorUIResource of black is used.

Parameters:
table - the UIDefaults object the values are added to
systemColors - array of name-color pairs as described in initSystemColorDefaults(UIDefaults)
useNative - whether the color is obtained from SystemColor or Color.decode
Throws:
NullPointerException - if systemColors is null; or systemColors is not empty, and table is null; or one of the names of the name-color pairs is null; or useNative is false and one of the colors of the name-color pairs is null
ArrayIndexOutOfBoundsException - if useNative is false and systemColors.length is odd
See Also:
initSystemColorDefaults(javax.swing.UIDefaults) , SystemColor , Color.decode(String)

initComponentDefaults


protected void initComponentDefaults(UIDefaults table)
Populates table with the defaults for the basic look and feel.

Parameters:
table - the UIDefaults to add the values to
Throws:
NullPointerException - if table is null

getAudioActionMap


protected ActionMap getAudioActionMap()
Returns an ActionMap containing the audio actions for this look and feel. Returns an ActionMap.

The returned This ActionMap contains Actions that embody the ability to render an auditory cue. These auditory cues map onto user and system activities that may be useful for an end user to know about (such as a dialog box appearing).

At the appropriate time, time in a JComponent UI's lifecycle, the ComponentUI is responsible for obtaining an getting the appropriate Action out of the ActionMap and passing it on to playSound.

This method first looks up the ActionMap from the defaults using the key "AuditoryCues.actionMap". The Actions in this ActionMap are created by the createAudioAction method.

If the value is non-null, it is returned. If the value of the default "AuditoryCues.actionMap" is null and the value of the default "AuditoryCues.cueList" is non-null, an ActionMapUIResource is created and populated. Population is done by iterating over each of the elements of the "AuditoryCues.cueList" array, and invoking createAudioAction() to create an Action for each element. The resulting Action is placed in the ActionMapUIResource, using the array element as the key. For example, if the "AuditoryCues.cueList" array contains a single-element, "audioKey", the ActionMapUIResource is created, then populated by way of actionMap.put(cueList[0], createAudioAction(cueList[0])).

If the value of the default "AuditoryCues.actionMap" is null and the value of the default "AuditoryCues.cueList" is null, an empty ActionMapUIResource is created.

Returns:
an ActionMap containing Actions responsible for playing rendering auditory cues
Throws:
ClassCastException - if the value of the default "AuditoryCues.actionMap" is not an ActionMap, or the value of the default "AuditoryCues.cueList" is not an Object[]
Since:
1.4
See Also:
createAudioAction(java.lang.Object) , playSound(Action)

createAudioAction


protected Action createAudioAction(Object key)
Creates and returns an Action used to play a sound. Returns an Action.

If key is non-null, an Action is created using the value from the defaults with key key. The value identifies the sound resource to load when actionPerformed is invoked on the Action. The sound resource is loaded into a byte[] by way of getClass().getResourceAsStream(). This Action contains the information and logic to render an auditory cue. The Object that is passed to this method contains the information needed to render the auditory cue. Normally, this Object is a String that points to an audio file relative to the current package. This Action's actionPerformed method is fired by the playSound method.

Parameters:
key - the key identifying the audio action
Returns:
an Action used to play the source, or null if key is null an Action which knows how to render the auditory cue for one particular system or user activity
Since:
1.4
See Also:
playSound(Action)

playSound


protected void playSound(Action audioAction)
If necessary, invokes actionPerformed on audioAction to play a sound. The actionPerformed method is invoked if the value of the "AuditoryCues.playList" default is a non-null Object[] containing a String entry equal to the name of the audioAction. Decides whether to fire the Action that is passed into it and, if needed, fires the Action's actionPerformed method. This has the effect of rendering the audio appropriate for the situation.

The set of possible cues to be played are stored in the default table value "AuditoryCues.cueList". The cues that will be played are stored in "AuditoryCues.playList".

Parameters:
audioAction - an Action that knows how to render the audio associated with the system or user activity that is occurring; a value of null, is ignored occurring
Throws:
ClassCastException - if audioAction is non-null and the value of the default "AuditoryCues.playList" is not an Object[]
Since:
1.4