javax.swing.plaf.basic
Class BasicLookAndFeel

java.lang.Object
  extended byjavax.swing.LookAndFeel
      extended byjavax.swing.plaf.basic.BasicLookAndFeel
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MetalLookAndFeel

public abstract class BasicLookAndFeel
extends LookAndFeel
implements Serializable

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.

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 XMLEncoder.

Author:
unattributed
See Also:
Serialized Form

Nested Class Summary
private  class BasicLookAndFeel.AudioAction
          Pass the name String to the super constructor.
 
Field Summary
private  Object audioLock
          Lock used when manipulating clipPlaying.
private  javax.sound.sampled.Clip clipPlaying
          The Clip that is currently playing (set in AudioAction).
 
Constructor Summary
BasicLookAndFeel()
           
 
Method Summary
(package private) static void compositeRequestFocus(Component component)
           
protected  Action createAudioAction(Object key)
          Returns an Action.
private static void doPrivileged(Runnable doRun)
          Utility method that helps get permission for loading audio files.
protected  ActionMap getAudioActionMap()
          Returns an ActionMap.
 UIDefaults getDefaults()
          This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table.
protected  void initClassDefaults(UIDefaults table)
          Initialize the uiClassID to BasicComponentUI mapping.
protected  void initComponentDefaults(UIDefaults table)
           
private  void initResourceBundle(UIDefaults table)
          Initialize the defaults table with the name of the ResourceBundle used for getting localized defaults.
protected  void initSystemColorDefaults(UIDefaults table)
          Load the SystemColors into the defaults table.
private  byte[] loadAudioData(String soundFile)
          Utility method that loads audio bits for the specified soundFile filename.
protected  void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
          If this is the native look and feel the initial values for the system color properties are the same as the SystemColor constants.
protected  void playSound(Action audioAction)
          Decides whether to fire the Action that is passed into it and, if needed, fires the Action's actionPerformed method.
 
Methods inherited from class javax.swing.LookAndFeel
getDescription, getDesktopPropertyValue, getID, getName, getSupportsWindowDecorations, initialize, installBorder, installColors, installColorsAndFont, 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, wait, wait, wait
 

Field Detail

audioLock

private Object audioLock
Lock used when manipulating clipPlaying.


clipPlaying

private javax.sound.sampled.Clip clipPlaying
The Clip that is currently playing (set in AudioAction).

Constructor Detail

BasicLookAndFeel

public BasicLookAndFeel()
Method Detail

getDefaults

public UIDefaults getDefaults()
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.

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

initClassDefaults

protected void initClassDefaults(UIDefaults table)
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.

See Also:
getDefaults()

initSystemColorDefaults

protected void initSystemColorDefaults(UIDefaults table)
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.


loadSystemColors

protected void loadSystemColors(UIDefaults table,
                                String[] systemColors,
                                boolean useNative)
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.


initResourceBundle

private void initResourceBundle(UIDefaults table)
Initialize the defaults table with the name of the ResourceBundle used for getting localized defaults. Also initialize the default locale used when no locale is passed into UIDefaults.get(). The default locale should generally not be relied upon. It is here for compatability with releases prior to 1.4.


initComponentDefaults

protected void initComponentDefaults(UIDefaults table)

getAudioActionMap

protected ActionMap getAudioActionMap()
Returns an ActionMap.

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 in a JComponent UI's lifecycle, the ComponentUI is responsible for getting the appropriate Action out of the ActionMap and passing it on to playSound.

The Actions in this ActionMap are created by the createAudioAction method.

Returns:
an ActionMap containing Actions responsible for rendering auditory cues
Since:
1.4
See Also:
createAudioAction(java.lang.Object), playSound(Action)

createAudioAction

protected Action createAudioAction(Object key)
Returns an Action.

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.

Returns:
an Action which knows how to render the auditory cue for one particular system or user activity
Since:
1.4
See Also:
playSound(Action)

doPrivileged

private static final void doPrivileged(Runnable doRun)
Utility method that helps get permission for loading audio files. This is an exact copy of javax.swing.SwingUtilities#doPrivileged(final Runnable). The SwingUtilities version is unusable here as it is package private.

Parameters:
doRun - the object that needs special access, in this case, to the file system
Since:
1.4
See Also:
javax.swing.SwingUtilities#doPrivileged(final Runnable)

loadAudioData

private byte[] loadAudioData(String soundFile)
Utility method that loads audio bits for the specified soundFile filename. If this method is unable to build a viable path name from the baseClass and soundFile passed into this method, it will return null.

Parameters:
soundFile - the name of the audio file to be retrieved from disk
Returns:
A byte[] with audio data or null
Since:
1.4

playSound

protected void playSound(Action 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
Since:
1.4

compositeRequestFocus

static void compositeRequestFocus(Component component)