Class SynthLookAndFeel
java.lang.Object
javax.swing.LookAndFeel
javax.swing.plaf.basic.BasicLookAndFeel
javax.swing.plaf.synth.SynthLookAndFeel
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NimbusLookAndFeel
SynthLookAndFeel provides the basis for creating a customized look and
feel. SynthLookAndFeel does not directly provide a look, all painting is
delegated.
You need to either provide a configuration file, by way of the
load(InputStream, Class)
method, or provide your own SynthStyleFactory
to setStyleFactory(SynthStyleFactory)
. Refer to the
package summary for an example of
loading a file, and SynthStyleFactory
for
an example of providing your own SynthStyleFactory
to
setStyleFactory
.
SynthIcon
interface provides
paintIcon(synthContext, graphics, x, y, width, height)
method that
allows to draw the icon with the given SynthContext
.
Warning:
This class implements Serializable
as a side effect of it
extending BasicLookAndFeel
. It is not intended to be serialized.
An attempt to serialize it will
result in NotSerializableException
.
- Since:
- 1.5
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentUI
Creates the Synth look and feelComponentUI
for the passed inJComponent
.Returns the defaults for this SynthLookAndFeel.Returns a textual description of SynthLookAndFeel.getID()
Return a string that identifies this look and feel.getName()
Return a short string that identifies this look and feel.static Region
Returns the Region for the JComponentc
.static SynthStyle
getStyle
(JComponent c, Region region) Gets a SynthStyle for the specified region of the specified component.static SynthStyleFactory
Returns the current SynthStyleFactory.void
Called by UIManager when this look and feel is installed.boolean
Returns false, SynthLookAndFeel is not a native look and feel.boolean
Returns true, SynthLookAndFeel is always supported.void
load
(InputStream input, Class<?> resourceBase) Loads the set ofSynthStyle
s that will be used by thisSynthLookAndFeel
.static void
setStyleFactory
(SynthStyleFactory cache) Sets the SynthStyleFactory that the UI classes provided by synth will use to obtain a SynthStyle.boolean
Returns whether or not the UIs should update theirSynthStyles
from theSynthStyleFactory
when the ancestor of theJComponent
changes.protected boolean
Returns whether or not the UIs should update their styles when a particular event occurs.void
Called by UIManager when this look and feel is uninstalled.static void
Updates the style associated withc
, and all its children.Methods declared in class BasicLookAndFeel
createAudioAction, getAudioActionMap, initClassDefaults, initComponentDefaults, initSystemColorDefaults, loadSystemColors, playSound
Modifier and TypeMethodDescriptionprotected Action
createAudioAction
(Object key) Creates and returns anAction
used to play a sound.protected ActionMap
Returns anActionMap
containing the audio actions for this look and feel.protected void
initClassDefaults
(UIDefaults table) Populatestable
with mappings fromuiClassID
to the fully qualified name of the ui class.protected void
initComponentDefaults
(UIDefaults table) Populatestable
with the defaults for the basic look and feel.protected void
Populatestable
with system colors.protected void
loadSystemColors
(UIDefaults table, String[] systemColors, boolean useNative) Populatestable
with thename-color
pairs insystemColors
.protected void
If necessary, invokesactionPerformed
onaudioAction
to play a sound.Methods declared in class LookAndFeel
getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getLayoutStyle, getSupportsWindowDecorations, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninstallBorder
Modifier and TypeMethodDescriptionstatic Object
getDesktopPropertyValue
(String systemPropertyName, Object fallbackValue) Returns the value of the specified system desktop property by invokingToolkit.getDefaultToolkit().getDesktopProperty()
.getDisabledIcon
(JComponent component, Icon icon) Returns anIcon
with a disabled appearance.getDisabledSelectedIcon
(JComponent component, Icon icon) Returns anIcon
for use by disabled components that are also selected.Returns theLayoutStyle
for this look and feel.boolean
Returnstrue
if theLookAndFeel
returnedRootPaneUI
instances support providingWindow
decorations in aJRootPane
.static void
installBorder
(JComponent c, String defaultBorderName) Convenience method for setting a component's border property with a value from the defaults.static void
installColors
(JComponent c, String defaultBgName, String defaultFgName) Convenience method for setting a component's foreground and background color properties with values from the defaults.static void
installColorsAndFont
(JComponent c, String defaultBgName, String defaultFgName, String defaultFontName) Convenience method for setting a component's foreground, background and font properties with values from the defaults.static void
installProperty
(JComponent c, String propertyName, Object propertyValue) 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.static void
loadKeyBindings
(InputMap retMap, Object[] keys) Populates anInputMap
with the specified bindings.static ComponentInputMap
makeComponentInputMap
(JComponent c, Object[] keys) Creates aComponentInputMapUIResource
fromkeys
.static Object
Creates and returns aUIDefault.LazyValue
that loads an image.static InputMap
makeInputMap
(Object[] keys) Creates anInputMapUIResource
fromkeys
.static JTextComponent.KeyBinding[]
makeKeyBindings
(Object[] keyBindingList) Convenience method for building an array ofKeyBindings
.void
provideErrorFeedback
(Component component) Invoked when the user attempts an invalid operation, such as pasting into an uneditableJTextField
that has focus.toString()
Returns a string that displays and identifies this object's properties.static void
Convenience method for uninstalling a border.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
SynthLookAndFeel
public SynthLookAndFeel()Creates a SynthLookAndFeel.For the returned
SynthLookAndFeel
to be useful you need to invokeload
to specify the set ofSynthStyle
s, or invokesetStyleFactory
.- See Also:
-
-
Method Details
-
setStyleFactory
Sets the SynthStyleFactory that the UI classes provided by synth will use to obtain a SynthStyle.- Parameters:
cache
- SynthStyleFactory the UIs should use.
-
getStyleFactory
Returns the current SynthStyleFactory.- Returns:
- SynthStyleFactory
-
getStyle
Gets a SynthStyle for the specified region of the specified component. This is not for general consumption, only custom UIs should call this method.- Parameters:
c
- JComponent to get the SynthStyle forregion
- Identifies the region of the specified component- Returns:
- SynthStyle to use.
-
updateStyles
Updates the style associated withc
, and all its children. This is a lighter version ofSwingUtilities.updateComponentTreeUI
.- Parameters:
c
- Component to update style for.
-
getRegion
Returns the Region for the JComponentc
.- Parameters:
c
- JComponent to fetch the Region for- Returns:
- Region corresponding to
c
-
createUI
Creates the Synth look and feelComponentUI
for the passed inJComponent
.- Parameters:
c
- JComponent to create theComponentUI
for- Returns:
- ComponentUI to use for
c
-
load
Loads the set ofSynthStyle
s that will be used by thisSynthLookAndFeel
.resourceBase
is used to resolve any path based resources, for example anImage
would be resolved byresourceBase.getResource(path)
. Refer to Synth File Format for more information.- Parameters:
input
- InputStream to load fromresourceBase
- used to resolve any images or other resources- Throws:
ParseException
- if there is an error in parsingIllegalArgumentException
- if input or resourceBase isnull
-
initialize
public void initialize()Called by UIManager when this look and feel is installed.- Overrides:
initialize
in classLookAndFeel
- See Also:
-
uninitialize
public void uninitialize()Called by UIManager when this look and feel is uninstalled.- Overrides:
uninitialize
in classLookAndFeel
- See Also:
-
getDefaults
Returns the defaults for this SynthLookAndFeel.- Overrides:
getDefaults
in classBasicLookAndFeel
- Returns:
- Defaults table.
- See Also:
-
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()Returns true, SynthLookAndFeel is always supported.- Specified by:
isSupportedLookAndFeel
in classLookAndFeel
- Returns:
- true.
- See Also:
-
isNativeLookAndFeel
public boolean isNativeLookAndFeel()Returns false, SynthLookAndFeel is not a native look and feel.- Specified by:
isNativeLookAndFeel
in classLookAndFeel
- Returns:
- false
-
getDescription
Returns a textual description of SynthLookAndFeel.- Specified by:
getDescription
in classLookAndFeel
- Returns:
- textual description of synth.
-
getName
Return a short string that identifies this look and feel.- Specified by:
getName
in classLookAndFeel
- Returns:
- a short string identifying this look and feel.
-
getID
Return a string that identifies this look and feel.- Specified by:
getID
in classLookAndFeel
- Returns:
- a short string identifying this look and feel.
-
shouldUpdateStyleOnAncestorChanged
public boolean shouldUpdateStyleOnAncestorChanged()Returns whether or not the UIs should update theirSynthStyles
from theSynthStyleFactory
when the ancestor of theJComponent
changes. A subclass that provided aSynthStyleFactory
that based the return value fromgetStyle
off the containment hierarchy would override this method to return true.- Returns:
- whether or not the UIs should update their
SynthStyles
from theSynthStyleFactory
when the ancestor changed.
-
shouldUpdateStyleOnEvent
Returns whether or not the UIs should update their styles when a particular event occurs.- Parameters:
ev
- aPropertyChangeEvent
- Returns:
- whether or not the UIs should update their styles
- Since:
- 1.7
-