with system colors. The following values are
"infoText" | theme.getPrimaryControlInfo() The value theme corresponds to the current MetalTheme .
Parameters:
- table - the {@code UIDefaults} object the values are added to
Throws:
- NullPointerException - if {@code table} is {@code null}
publicstatic void
installBorder
( JComponent c, String defaultBorderName)
[Inherited From LookAndFeel]
Convenience method for setting a component's border property with
a value from the defaults.
Convenience method for setting a component's border property with a value from the defaults. The border is only set if the border is null or an instance of UIResource .
Parameters:
- c - component to set the border on
- defaultBorderName - key specifying the border
Throws:
- NullPointerException - as described in
exceptions
publicstatic void
installColors
( JComponent c, String defaultBgName, String defaultFgName)
[Inherited From LookAndFeel]
Convenience method for setting a component's foreground
and background color properties with values from the
defaults.
publicstatic void
installColorsAndFont
( JComponent c, String defaultBgName, String defaultFgName, String defaultFontName)
[Inherited From LookAndFeel]
Convenience method for setting a component's foreground,
background and font properties with values from the
defaults.
publicstatic void
installProperty
( JComponent c, String propertyName, Object propertyValue)
[Inherited From LookAndFeel]
Convenience method for installing a property with the specified name
and value on a component if that property has not already been set
by the developer.
Convenience method for installing a property with the specified name and value on a component if that property has not already been set by the developer. This method is intended to be used by ui delegate instances that need to specify a default value for a property of primitive type (boolean, int, ..), but do not wish to override a value set by the client. Since primitive property values cannot be wrapped with the UIResource marker, this method uses private state to determine whether the property has been set by the client.
Parameters:
- c - target component to set the property on
- propertyName - name of the property to set
- propertyValue - value of the property
Throws:
- IllegalArgumentException - if the specified property is not
one which can be set using this method
- ClassCastException - if the property value has not been set
by the developer and the type does not match the property's type
- NullPointerException - if {@code c} is {@code null}, or the
named property has not been set by the developer and
{@code propertyValue} is {@code null}
Since:
1.5
public boolean
isNativeLookAndFeel
()
[Specified in LookAndFeel]
Returns false ; MetalLookAndFeel is not a native
look and feel.
Returns false ; MetalLookAndFeel is not a native look and feel.
Returns:
{@code false}
public boolean
isSupportedLookAndFeel
()
[Specified in LookAndFeel]
Returns true ; MetalLookAndFeel can be run on
any platform.
Returns true ; MetalLookAndFeel can be run on any platform.
Returns:
{@code true}
pack-privatestatic boolean
isWindows
()
Returns true if running on Windows.
publicstatic void
loadKeyBindings
( InputMap retMap, Object keys)
[Inherited From LookAndFeel]
Populates an InputMap with the specified bindings.
Populates an InputMap with the specified bindings.
The bindings are supplied as a list of alternating
keystroke-action key pairs. The keystroke is either
an instance of KeyStroke , or a String
that identifies the KeyStroke for the binding. Refer
to KeyStroke.getKeyStroke(String) for the specific
format. The action key part of the pair is the key
registered in the InputMap for the KeyStroke .
The following illustrates loading an InputMap with two
key-action pairs:
LookAndFeel.loadKeyBindings(inputMap, new Object[] {
"control X", "cut",
"control V", "paste"
});
Supplying a null list of bindings (keys ) does not
change retMap in any way.
Specifying a null action key results in
removing the keystroke's entry from the InputMap .
A null keystroke is ignored.
Parameters:
- retMap - {@code InputMap} to add the {@code key-action}
pairs to
- keys - bindings to add to {@code retMap}
Throws:
- NullPointerException - if {@code keys} is
{@code non-null}, not empty, and {@code retMap} is
{@code null}
Since:
1.3
See Also:
KeyStroke.getKeyStroke(String) ,
InputMap ,
protected void
loadSystemColors
( UIDefaults table, String systemColors, boolean useNative)
[Inherited From BasicLookAndFeel]
Populates table with the name-color pairs in
systemColors .
Populates table with the name-color pairs in
systemColors . Refer to
BasicLookAndFeel.initSystemColorDefaults(UIDefaults) for details on
the format of systemColors .
An entry is added to table for each of the name-color
pairs in systemColors . The entry key is
the name of the name-color pair.
The value of the entry corresponds to the color of the
name-color pair. The value of the entry is calculated
in one of two ways. With either approach the value is always a
ColorUIResource .
If useNative is false , the color is
created by using Color.decode to convert the String into a Color . If decode can not convert
the String into a Color (NumberFormatException is thrown) then a ColorUIResource of black is used.
If useNative is true , the color is the
value of the field in SystemColor with the same name as
the name of the name-color pair. If the field
is not valid, a ColorUIResource of black is used.
Parameters:
- table - the {@code UIDefaults} object the values are added to
- systemColors - array of {@code name-color} pairs as described
in {@link #initSystemColorDefaults(UIDefaults)}
- useNative - whether the color is obtained from {@code SystemColor}
or {@code Color.decode}
Throws:
- NullPointerException - if {@code systemColors} is {@code null}; or
{@code systemColors} is not empty, and {@code table} is
{@code null}; or one of the
names of the {@code name-color} pairs is {@code null}; or
{@code useNative} is {@code false} and one of the
{@code colors} of the {@code name-color} pairs is {@code null}
- ArrayIndexOutOfBoundsException - if {@code useNative} is
{@code false} and {@code systemColors.length} is odd
See Also:
BasicLookAndFeel.initSystemColorDefaults(javax.swing.UIDefaults) ,
SystemColor ,
Color.decode(String) ,
publicstatic Object
makeIcon
( Class< Object> baseClass, String gifFile)
[Inherited From LookAndFeel]
Creates and returns a UIDefault.LazyValue that loads an
image.
Creates and returns a UIDefault.LazyValue that loads an
image. The returned value is an implementation of UIDefaults.LazyValue . When createValue is invoked on
the returned object, the image is loaded. If the image is non-null , it is then wrapped in an Icon that implements UIResource . The image is loaded using Class.getResourceAsStream(gifFile) .
This method does not check the arguments in any way. It is
strongly recommended that non-null values are supplied else
exceptions may occur when createValue is invoked on the
returned object.
Returns:
a {@code UIDefaults.LazyValue}; when resolved the
{@code LazyValue} loads the specified image
Parameters:
- baseClass - {@code Class} used to load the resource
- gifFile - path to the image to load
See Also:
UIDefaults.LazyValue ,
Icon ,
Class.getResourceAsStream(String) ,
publicstatic InputMap
makeInputMap
( Object keys)
[Inherited From LookAndFeel]
Creates a InputMapUIResource from keys .
Creates a InputMapUIResource from keys . This is a convenience method for creating a new InputMapUIResource , invoking loadKeyBindings(map, keys) , and returning the InputMapUIResource .
Returns:
newly created and populated {@code InputMapUIResource}
Parameters:
- keys - alternating pairs of {@code keystroke-action key}
pairs as described in {@link #loadKeyBindings}
Since:
1.3
See Also:
LookAndFeel.loadKeyBindings(javax.swing.InputMap, java.lang.Object[]) ,
publicstatic KeyBinding
makeKeyBindings
( Object keyBindingList)
[Inherited From LookAndFeel]
Convenience method for building an array of KeyBindings .
Convenience method for building an array of KeyBindings . While this method is not deprecated, developers
should instead use ActionMap and InputMap for
supplying key bindings.
This method returns an array of KeyBindings , one for each
alternating key-action pair in keyBindingList .
A key can either be a String in the format
specified by the KeyStroke.getKeyStroke method, or
a KeyStroke . The action part of the pair is a
String that corresponds to the name of the Action .
The following example illustrates creating a KeyBinding array
from six alternating key-action pairs:
JTextComponent.KeyBinding[] multilineBindings = makeKeyBindings( new Object[] {
"UP", DefaultEditorKit.upAction,
"DOWN", DefaultEditorKit.downAction,
"PAGE_UP", DefaultEditorKit.pageUpAction,
"PAGE_DOWN", DefaultEditorKit.pageDownAction,
"ENTER", DefaultEditorKit.insertBreakAction,
"TAB", DefaultEditorKit.insertTabAction
});
If keyBindingList's length is odd, the last element is
ignored.
Supplying a null value for either the key or
action part of the key-action pair results in
creating a KeyBinding with the corresponding value
null . As other parts of Swing's expect non-null values
in a KeyBinding , you should avoid supplying null as
either the key or action part of the key-action
pair.
Returns:
an array of {@code KeyBindings}
Parameters:
- keyBindingList - an array of {@code key-action} pairs
Throws:
- NullPointerException - if {@code keyBindingList} is {@code null}
- ClassCastException - if the {@code key} part of the pair is
not a {@code KeyStroke} or {@code String}, or the
{@code action} part of the pair is not a {@code String}
See Also:
ActionMap ,
InputMap ,
KeyStroke.getKeyStroke(char) ,
protected void
playSound
( Action audioAction)
[Inherited From BasicLookAndFeel]
If necessary, invokes actionPerformed on
audioAction to play a sound.
If necessary, invokes actionPerformed on audioAction to play a sound. The actionPerformed method is invoked if the value of the "AuditoryCues.playList" default is a non-null Object[] containing a String entry equal to the name of the audioAction .
Parameters:
- audioAction - an Action that knows how to render the audio
associated with the system or user activity
that is occurring; a value of {@code null}, is
ignored
Throws:
- ClassCastException - if {@code audioAction} is {@code non-null}
and the value of the default {@code "AuditoryCues.playList"}
is not an {@code Object[]}
Since:
1.4
public void
provideErrorFeedback
( Component component)
[Overrides LookAndFeel]
Invoked when the user attempts an invalid operation,
such as pasting into an uneditable JTextField
that has focus.
Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus. The default implementation beeps. Subclasses that wish different behavior should override this and provide the additional feedback.
Since:
1.4
publicstatic void
setCurrentTheme
( MetalTheme theme)
Set the theme used by MetalLookAndFeel .
Set the theme used by MetalLookAndFeel .
After the theme is set, MetalLookAndFeel needs to be
re-installed and the uis need to be recreated. The following
shows how to do this:
MetalLookAndFeel.setCurrentTheme(theme);
// re-install the Metal Look and Feel
UIManager.setLookAndFeel(new MetalLookAndFeel());
// Update the ComponentUIs for all Components. This
// needs to be invoked for all windows.
SwingUtilities.updateComponentTreeUI(rootComponent);
If this is not done the results are undefined.
Parameters:
- theme - the theme to use
Throws:
- NullPointerException - if {@code theme} is {@code null}
See Also:
MetalLookAndFeel.getCurrentTheme() ,
public String
toString
()
[Inherited From LookAndFeel]
Returns a string that displays and identifies this
object's properties.
Returns a string that displays and identifies this object's properties.
Returns:
a String representation of this object
public void
uninitialize
()
[Inherited From BasicLookAndFeel]
Uninitializes the look and feel.
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.
publicstatic void
uninstallBorder
( JComponent c)
[Inherited From LookAndFeel]
Convenience method for uninstalling a border.
Convenience method for uninstalling a border. If the border of the component is a UIResource , it is set to null .
Parameters:
- c - component to uninstall the border on
Throws:
- NullPointerException - if {@code c} is {@code null}
pack-privatestatic boolean
useSystemFonts
()
Returns true if system fonts should be used, this is only useful
for windows.
pack-privatestatic boolean
usingOcean
()
Returns true if we're using the Ocean Theme.
Fields
Nested Classes
|