public class

WindowsLookAndFeel

extends BasicLookAndFeel
java.lang.Object
   ↳ javax.swing.LookAndFeel
     ↳ javax.swing.plaf.basic.BasicLookAndFeel
       ↳ com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Known Direct Subclasses

Class Overview

Implements the Windows95/98/NT/2000 Look and Feel. UI classes not implemented specifically for Windows will default to those implemented in Basic.

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. A future release of Swing will provide support for long term persistence.

Summary

Public Constructors
WindowsLookAndFeel()
Public Methods
String getDescription()
Return a one line description of this look and feel implementation, e.g.
Icon getDisabledIcon(JComponent component, Icon icon)
Returns an Icon with a disabled appearance.
String getID()
Return a string that identifies this look and feel.
LayoutStyle getLayoutStyle()
Returns the LayoutStyle for this look and feel.
String getName()
Return a short string that identifies this look and feel, e.g.
void initialize()
Initializes the look and feel.
static boolean isClassicWindows()
Gets the state of the flag which indicates if the old Windows look and feel should be rendered.
static boolean isMnemonicHidden()
Gets the state of the hide mnemonic flag.
boolean isNativeLookAndFeel()
If the underlying platform has a "native" look and feel, and this is an implementation of it, return true.
boolean isSupportedLookAndFeel()
Return true if the underlying platform supports and or permits this look and feel.
void provideErrorFeedback(Component component)

Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.

static void setMnemonicHidden(boolean hide)
Sets the state of the hide mnemonic flag.
void uninitialize()
Uninitializes the look and feel.
Protected Methods
Action createAudioAction(Object key)
Returns an Action.
void initClassDefaults(UIDefaults table)
Initialize the uiClassID to BasicComponentUI mapping.
void initComponentDefaults(UIDefaults table)
Populates table with the defaults for the basic look and feel.
void initSystemColorDefaults(UIDefaults table)
Load the SystemColors into the defaults table.
[Expand]
Inherited Methods
From class javax.swing.plaf.basic.BasicLookAndFeel
From class javax.swing.LookAndFeel
From class java.lang.Object

Public Constructors

public WindowsLookAndFeel ()

Public Methods

public String getDescription ()

Return a one line description of this look and feel implementation, e.g. "The CDE/Motif Look and Feel". This string is intended for the user, e.g. in the title of a window or in a ToolTip message.

Returns
  • short description for the look and feel

public Icon getDisabledIcon (JComponent component, Icon icon)

Returns an Icon with a disabled appearance. This method is used to generate a disabled Icon when one has not been specified. For example, if you create a JButton and only specify an Icon via setIcon this method will be called to generate the disabled Icon. If null is passed as icon this method returns null.

Some look and feels might not render the disabled Icon, in which case they will ignore this.

Parameters
component JComponent that will display the Icon, may be null
icon Icon to generate the disabled icon from
Returns
  • disabled Icon, or null if a suitable Icon can not be generated

public String getID ()

Return a string that identifies this look and feel. This string will be used by applications/services that want to recognize well known look and feel implementations. Presently the well known names are "Motif", "Windows", "Mac", "Metal". Note that a LookAndFeel derived from a well known superclass that doesn't make any fundamental changes to the look or feel shouldn't override this method.

Returns
  • identifier for the look and feel

public LayoutStyle getLayoutStyle ()

Returns the LayoutStyle for this look and feel. This never returns null.

You generally don't use the LayoutStyle from the look and feel, instead use the LayoutStyle method getInstance.

Returns
  • the LayoutStyle for this look and feel

public String getName ()

Return a short string that identifies this look and feel, e.g. "CDE/Motif". This string should be appropriate for a menu item. Distinct look and feels should have different names, e.g. a subclass of MotifLookAndFeel that changes the way a few components are rendered should be called "CDE/Motif My Way"; something that would be useful to a user trying to select a L&F from a list of names.

Returns
  • short identifier for the look and feel

public void initialize ()

Initializes the look and feel. While this method is public, it should only be invoked by the UIManager when a look and feel is installed as the current look and feel. This method is invoked before the UIManager invokes getDefaults. This method is intended to perform any initialization for the look and feel. Subclasses should do any one-time setup they need here, rather than in a static initializer, because look and feel class objects may be loaded just to discover that isSupportedLookAndFeel() returns false.

public static boolean isClassicWindows ()

Gets the state of the flag which indicates if the old Windows look and feel should be rendered. This flag is used by the component UI delegates as a hint to determine which style the component should be rendered.

Returns
  • true if Windows 95 and Windows NT 4 look and feel should be rendered

public static boolean isMnemonicHidden ()

Gets the state of the hide mnemonic flag. This only has meaning if this feature is supported by the underlying OS.

Returns
  • true if mnemonics are hidden, otherwise, false

public boolean isNativeLookAndFeel ()

If the underlying platform has a "native" look and feel, and this is an implementation of it, return true. For example, when the underlying platform is Solaris running CDE a CDE/Motif look and feel implementation would return true.

Returns
  • true if this look and feel represents the underlying platform look and feel

public boolean isSupportedLookAndFeel ()

Return true if the underlying platform supports and or permits this look and feel. This method returns false if the look and feel depends on special resources or legal agreements that aren't defined for the current platform.

Returns
  • true if this is a supported look and feel

public void provideErrorFeedback (Component component)

Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.

If the user has enabled visual error indication on the desktop, this method will flash the caption bar of the active window. The user can also set the property awt.visualbell=true to achieve the same results.

Parameters
component Component the error occured in, may be null indicating the error condition is not directly associated with a Component.

public static void setMnemonicHidden (boolean hide)

Sets the state of the hide mnemonic flag. This flag is used by the component UI delegates to determine if the mnemonic should be rendered. This method is a non operation if the underlying operating system does not support the mnemonic hiding feature.

Parameters
hide true if mnemonics should be hidden

public void uninitialize ()

Uninitializes the look and feel. While this method is public, it should only be invoked by the UIManager when the look and feel is uninstalled. For example, UIManager.setLookAndFeel invokes this when the look and feel is changed.

Subclasses may choose to free up some resources here.

Protected Methods

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 a Toolkit desktopProperty. This desktopProperty is resolved by AWT and the Windows OS.

This Action's actionPerformed method is fired by the playSound method.

Parameters
key the key identifying the audio action
Returns
  • an Action which knows how to render the auditory cue for one particular system or user activity

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.

Parameters
table the UIDefaults instance the entries are added to
See Also

protected void initComponentDefaults (UIDefaults table)

Populates table with the defaults for the basic look and feel.

Parameters
table the UIDefaults to add the values to

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.

Parameters
table the UIDefaults object the values are added to