| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
createAudioAction(Object key) 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 |
initClassDefaults(UIDefaults table) Populates with mappings from to the fully qualified name of the ui class. |
protected void |
initComponentDefaults(UIDefaults table) 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 |
If necessary, invokes on to play a sound. |
void |
Uninitializes the look and feel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BasicLookAndFeel()
Method Detail |
---|
protected Action createAudioAction(Object key)
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()}.
key
- the key identifying the audio actionprotected ActionMap getAudioActionMap()
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.
public UIDefaults getDefaults()
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.
getDefaults
in class LookAndFeel
protected void initClassDefaults(UIDefaults table)
table
- the {@code UIDefaults} instance the entries are
added toprotected void initComponentDefaults(UIDefaults table)
table
- the {@code UIDefaults} to add the values topublic void initialize()
initialize
in class LookAndFeel
protected void initSystemColorDefaults(UIDefaults table)
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}.
table
- the {@code UIDefaults} object the values are added toprotected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
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.
table
- the {@code UIDefaults} object the values are added tosystemColors
- 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}protected void playSound(Action audioAction)
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
ignoredpublic void uninitialize()
uninitialize
in class LookAndFeel
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |