Home » openjdk-7 » javax » swing » plaf » basic » [javadoc | source]
javax.swing.plaf.basic
abstract public class: BasicLookAndFeel [javadoc | source]
java.lang.Object
   javax.swing.LookAndFeel
      javax.swing.plaf.basic.BasicLookAndFeel

All Implemented Interfaces:
    java$io$Serializable

Direct Known Subclasses:
    NimbusLookAndFeel, SynthLookAndFeel, MetalLookAndFeel

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

Nested Class Summary:
class  BasicLookAndFeel.AWTEventHelper  This class contains listener that watches for all the mouse events that can possibly invoke popup on the component 
Field Summary
static  boolean needsEventHelper    Whether or not the developer has created a JPopupMenu. 
 AWTEventHelper invocator     
Method from javax.swing.plaf.basic.BasicLookAndFeel Summary:
createAudioAction,   getAudioActionMap,   getDefaults,   getUIOfType,   initClassDefaults,   initComponentDefaults,   initSystemColorDefaults,   initialize,   installAWTEventListener,   installAudioActionMap,   loadSystemColors,   playSound,   playSound,   uninitialize
Methods from 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 from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.plaf.basic.BasicLookAndFeel Detail:
 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()}.

 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.

 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.

 static Object getUIOfType(ComponentUI ui,
    Class klass) 
    Returns the ui that is of type klass, or null if one can not be found.
 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"}.
 protected  void initComponentDefaults(UIDefaults table) 
    Populates {@code table} with the defaults for the basic look and feel.
 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}.
 public  void initialize() 
    {@inheritDoc}
  void installAWTEventListener() 
 static  void installAudioActionMap(ActionMap map) 
    Sets the parent of the passed in ActionMap to be the audio action map.
 protected  void loadSystemColors(UIDefaults table,
    String[] systemColors,
    boolean useNative) 
    Populates {@code table} with the {@code name-color} pairs in {@code systemColors}. Refer to #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.

 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}.
 static  void playSound(JComponent c,
    Object actionKey) 
    Helper method to play a named sound.
 public  void uninitialize() 
    {@inheritDoc}