- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- MetalLookAndFeel,- SynthLookAndFeel
public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable
 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 SummaryConstructors Constructor Description BasicLookAndFeel()
- 
Method SummaryModifier and Type Method Description protected ActioncreateAudioAction(Object key)Creates and returns anActionused to play a sound.protected ActionMapgetAudioActionMap()Returns anActionMapcontaining the audio actions for this look and feel.UIDefaultsgetDefaults()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 voidinitSystemColorDefaults(UIDefaults table)Populatestablewith system colors.protected voidloadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)Populatestablewith thename-colorpairs insystemColors.protected voidplaySound(Action audioAction)If necessary, invokesactionPerformedonaudioActionto play a sound.Methods declared in class javax.swing.LookAndFeelgetDescription, 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- 
BasicLookAndFeelpublic BasicLookAndFeel()
 
- 
- 
Method Details- 
getDefaultsReturns 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 class- LookAndFeel
- Returns:
- the look and feel defaults
- See Also:
- initClassDefaults(javax.swing.UIDefaults),- initSystemColorDefaults(javax.swing.UIDefaults),- initComponentDefaults(javax.swing.UIDefaults)
 
- 
initClassDefaultsPopulatestablewith 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- the- UIDefaultsinstance the entries are added to
- Throws:
- NullPointerException- if- tableis- null
- See Also:
- LookAndFeel,- getDefaults()
 
- 
initSystemColorDefaultsPopulatestablewith 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- the- UIDefaultsobject the values are added to
- Throws:
- NullPointerException- if- tableis- null
- See Also:
- SystemColor,- getDefaults(),- loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)
 
- 
loadSystemColorsPopulatestablewith 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- the- UIDefaultsobject the values are added to
- systemColors- array of- name-colorpairs as described in- initSystemColorDefaults(UIDefaults)
- useNative- whether the color is obtained from- SystemColoror- Color.decode
- Throws:
- NullPointerException- if- systemColorsis- null; or- systemColorsis not empty, and- tableis- null; or one of the names of the- name-colorpairs is- null; or- useNativeis- falseand one of the- colorsof the- name-colorpairs is- null
- ArrayIndexOutOfBoundsException- if- useNativeis- falseand- systemColors.lengthis odd
- See Also:
- initSystemColorDefaults(javax.swing.UIDefaults),- SystemColor,- Color.decode(String)
 
- 
initComponentDefaultsPopulatestablewith the defaults for the basic look and feel.- Parameters:
- table- the- UIDefaultsto add the values to
- Throws:
- NullPointerException- if- tableis- null
 
- 
getAudioActionMapReturns 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 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)
 
- 
createAudioActionCreates 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(Action)
 
- 
playSoundIf 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 of- null, is ignored
- Throws:
- ClassCastException- if- audioActionis- non-nulland the value of the default- "AuditoryCues.playList"is not an- Object[]
- Since:
- 1.4
 
 
-