- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MetalLookAndFeel,SynthLookAndFeel
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
has been added to the java.beans package.
Please see XMLEncoder.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ActioncreateAudioAction(Object key) Creates and returns anActionused to play a sound.protected ActionMapReturns anActionMapcontaining the audio actions for this look and feel.Returns the look and feel defaults.protected voidinitClassDefaults(UIDefaults table) Populatestablewith mappings fromuiClassIDto the fully qualified name of the ui class.protected voidinitComponentDefaults(UIDefaults table) Populatestablewith the defaults for the basic look and feel.protected voidPopulatestablewith system colors.protected voidloadSystemColors(UIDefaults table, String[] systemColors, boolean useNative) Populatestablewith thename-colorpairs insystemColors.protected voidIf necessary, invokesactionPerformedonaudioActionto play a sound.Methods declared in class javax.swing.LookAndFeel
getDescription, getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getID, getLayoutStyle, getName, getSupportsWindowDecorations, initialize, installBorder, installColors, installColorsAndFont, installProperty, isNativeLookAndFeel, isSupportedLookAndFeel, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninitialize, uninstallBorder
-
Constructor Details
-
BasicLookAndFeel
protected BasicLookAndFeel()Constructor for subclasses to call.
-
-
Method Details
-
getDefaults
Returns the look and feel defaults. The returnedUIDefaultsis populated by invoking, in order,initClassDefaults,initSystemColorDefaultsandinitComponentDefaults.While this method is public, it should only be invoked by the
UIManagerwhen the look and feel is set as the current look and feel and afterinitializehas been invoked.- Overrides:
getDefaultsin classLookAndFeel- Returns:
- the look and feel defaults
- See Also:
-
initClassDefaults
Populatestablewith mappings fromuiClassIDto the fully qualified name of the ui class. The value for a particularuiClassIDis"javax.swing.plaf.basic.Basic + uiClassID". For example, the value for theuiClassIDTreeUIis"javax.swing.plaf.basic.BasicTreeUI".- Parameters:
table- theUIDefaultsinstance the entries are added to- Throws:
NullPointerException- iftableisnull- See Also:
-
initSystemColorDefaults
Populatestablewith system colors. This creates an array ofname-colorpairs and invokesloadSystemColors.The name is a
Stringthat corresponds to the name of one of the staticSystemColorfields in theSystemColorclass. A name-color pair is created for every suchSystemColorfield.The
colorcorresponds to a hexStringas understood byColor.decode. For example, one of thename-colorpairs is"desktop"-"#005C5C". This corresponds to theSystemColorfielddesktop, with a color value ofnew Color(0x005C5C).The following shows two of the
name-colorpairs:String[] nameColorPairs = new String[] { "desktop", "#005C5C", "activeCaption", "#000080" }; loadSystemColors(table, nameColorPairs, isNativeLookAndFeel());As previously stated, this invokesloadSystemColorswith the suppliedtableandname-colorpair array. The last argument toloadSystemColorsindicates whether the value of the field inSystemColorshould be used. This method passes the value ofisNativeLookAndFeel()as the last argument toloadSystemColors.- Parameters:
table- theUIDefaultsobject the values are added to- Throws:
NullPointerException- iftableisnull- See Also:
-
loadSystemColors
Populatestablewith thename-colorpairs insystemColors. Refer toinitSystemColorDefaults(UIDefaults)for details on the format ofsystemColors.An entry is added to
tablefor each of thename-colorpairs insystemColors. The entry key is thenameof thename-colorpair.The value of the entry corresponds to the
colorof thename-colorpair. The value of the entry is calculated in one of two ways. With either approach the value is always aColorUIResource.If
useNativeisfalse, thecoloris created by usingColor.decodeto convert theStringinto aColor. Ifdecodecan not convert theStringinto aColor(NumberFormatExceptionis thrown) then aColorUIResourceof black is used.If
useNativeistrue, thecoloris the value of the field inSystemColorwith the same name as thenameof thename-colorpair. If the field is not valid, aColorUIResourceof black is used.- Parameters:
table- theUIDefaultsobject the values are added tosystemColors- array ofname-colorpairs as described ininitSystemColorDefaults(UIDefaults)useNative- whether the color is obtained fromSystemColororColor.decode- Throws:
NullPointerException- ifsystemColorsisnull; orsystemColorsis not empty, andtableisnull; or one of the names of thename-colorpairs isnull; oruseNativeisfalseand one of thecolorsof thename-colorpairs isnullArrayIndexOutOfBoundsException- ifuseNativeisfalseandsystemColors.lengthis odd- See Also:
-
initComponentDefaults
Populatestablewith the defaults for the basic look and feel.- Parameters:
table- theUIDefaultsto add the values to- Throws:
NullPointerException- iftableisnull
-
getAudioActionMap
Returns anActionMapcontaining the audio actions for this look and feel.The returned
ActionMapcontainsActionsthat 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
ComponentUIis responsible for obtaining anActionout of theActionMapand passing it toplaySound.This method first looks up the
ActionMapfrom the defaults using the key"AuditoryCues.actionMap".If the value is
non-null, it is returned. If the value of the default"AuditoryCues.actionMap"isnulland the value of the default"AuditoryCues.cueList"isnon-null, anActionMapUIResourceis created and populated. Population is done by iterating over each of the elements of the"AuditoryCues.cueList"array, and invokingcreateAudioAction()to create anActionfor each element. The resultingActionis placed in theActionMapUIResource, using the array element as the key. For example, if the"AuditoryCues.cueList"array contains a single-element,"audioKey", theActionMapUIResourceis created, then populated by way ofactionMap.put(cueList[0], createAudioAction(cueList[0])).If the value of the default
"AuditoryCues.actionMap"isnulland the value of the default"AuditoryCues.cueList"isnull, an emptyActionMapUIResourceis created.- Returns:
- an ActionMap containing
Actionsresponsible for playing auditory cues - Throws:
ClassCastException- if the value of the default"AuditoryCues.actionMap"is not anActionMap, or the value of the default"AuditoryCues.cueList"is not anObject[]- Since:
- 1.4
- See Also:
-
createAudioAction
Creates and returns anActionused to play a sound.If
keyisnon-null, anActionis created using the value from the defaults with keykey. The value identifies the sound resource to load whenactionPerformedis invoked on theAction. The sound resource is loaded into abyte[]by way ofgetClass().getResourceAsStream().- Parameters:
key- the key identifying the audio action- Returns:
- an
Actionused to play the source, ornullifkeyisnull - Since:
- 1.4
- See Also:
-
playSound
If necessary, invokesactionPerformedonaudioActionto play a sound. TheactionPerformedmethod is invoked if the value of the"AuditoryCues.playList"default is anon-nullObject[]containing aStringentry equal to the name of theaudioAction.- Parameters:
audioAction- an Action that knows how to render the audio associated with the system or user activity that is occurring; a value ofnull, is ignored- Throws:
ClassCastException- ifaudioActionisnon-nulland the value of the default"AuditoryCues.playList"is not anObject[]- Since:
- 1.4
-