This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


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.

Each of the {@code ComponentUI}s provided by {@code BasicLookAndFeel} derives its behavior from the defaults table. Unless otherwise noted each of the {@code ComponentUI} implementations in this package document the set of defaults they use. Unless otherwise noted the defaults are installed at the time {@code installUI} is invoked, and follow the recommendations outlined in {@code 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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Constructor Summary

          
 
Method Summary
protected Action

          Creates and returns an used to play a sound.
protected ActionMap

          Returns an ActionMap containing the audio actions for this look and feel.
 UIDefaults

          Returns the look and feel defaults.
protected void

          Populates with mappings from to the fully qualified name of the ui class.
protected void

          Populates with the defaults for the basic look and feel.
 void

          Initializes the look and feel.
protected void

          Populates with system colors.
protected void
loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)

          Populates with the pairs in .
protected void
playSound(Action audioAction)

          If necessary, invokes on to play a sound.
 void

          Uninitializes the look and feel.
 
Methods inherited from class javax.swing.LookAndFeel
getDefaults, getDescription, getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getID, getLayoutStyle, getName, getSupportsWindowDecorations, initialize, installBorder, installColors, installColorsAndFont, installProperty, isNativeLookAndFeel, isSupportedLookAndFeel, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninitialize, uninstallBorder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicLookAndFeel

public BasicLookAndFeel()
Method Detail

createAudioAction

protected Action createAudioAction(Object key)
Creates and returns an {@code Action} used to play a sound.

If {@code key} is {@code non-null}, an {@code Action} is created using the value from the defaults with key {@code key}. The value identifies the sound resource to load when {@code actionPerformed} is invoked on the {@code Action}. The sound resource is loaded into a {@code byte[]} by way of {@code getClass().getResourceAsStream()}.

Parameters:
key - the key identifying the audio action
Returns:
an {@code Action} used to play the source, or {@code null} if {@code key} is {@code null}

getAudioActionMap

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

The returned 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, the {@code ComponentUI} is responsible for obtaining an Action out of the ActionMap and passing it to playSound.

This method first looks up the {@code ActionMap} from the defaults using the key {@code "AuditoryCues.actionMap"}.

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

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

Returns:
an ActionMap containing {@code Actions} responsible for playing auditory cues

getDefaults

public UIDefaults getDefaults()
Returns the look and feel defaults. The returned {@code UIDefaults} is populated by invoking, in order, {@code initClassDefaults}, {@code initSystemColorDefaults} and {@code initComponentDefaults}.

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

Overrides:
getDefaults in class LookAndFeel
Returns:
the look and feel defaults

initClassDefaults

protected void initClassDefaults(UIDefaults table)
Populates {@code table} with mappings from {@code uiClassID} to the fully qualified name of the ui class. The value for a particular {@code uiClassID} is {@code "javax.swing.plaf.basic.Basic + uiClassID"}. For example, the value for the {@code uiClassID} {@code TreeUI} is {@code "javax.swing.plaf.basic.BasicTreeUI"}.

Parameters:
table - the {@code UIDefaults} instance the entries are added to

initComponentDefaults

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

Parameters:
table - the {@code UIDefaults} to add the values to

initialize

public void initialize()
{@inheritDoc}

Overrides:
initialize in class LookAndFeel

initSystemColorDefaults

protected void initSystemColorDefaults(UIDefaults table)
Populates {@code table} with system colors. This creates an array of {@code name-color} pairs and invokes {@code loadSystemColors}.

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

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

The following shows two of the {@code name-color} pairs:

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

Parameters:
table - the {@code UIDefaults} object the values are added to

loadSystemColors

protected void loadSystemColors(UIDefaults table,
                                String[] systemColors,
                                boolean useNative)
Populates {@code table} with the {@code name-color} pairs in {@code systemColors}. Refer to {@link #initSystemColorDefaults(UIDefaults)} for details on the format of {@code systemColors}.

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

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

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

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

Parameters:
table - the {@code UIDefaults} object the values are added to
systemColors - array of {@code name-color} pairs as described in {@link #initSystemColorDefaults(UIDefaults)}
useNative - whether the color is obtained from {@code SystemColor} or {@code Color.decode}

playSound

protected void playSound(Action audioAction)
If necessary, invokes {@code actionPerformed} on {@code audioAction} to play a sound. The {@code actionPerformed} method is invoked if the value of the {@code "AuditoryCues.playList"} default is a {@code non-null} {@code Object[]} containing a {@code String} entry equal to the name of the {@code audioAction}.

Parameters:
audioAction - an Action that knows how to render the audio associated with the system or user activity that is occurring; a value of {@code null}, is ignored

uninitialize

public void uninitialize()
{@inheritDoc}

Overrides:
uninitialize in class LookAndFeel


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.