APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.synth

public Class SynthLookAndFeel

extends BasicLookAndFeel
Class Inheritance
Known Direct Subclasses
com.sun.java.swing.plaf.gtk.GTKLookAndFeel, javax.swing.plaf.nimbus.NimbusLookAndFeel
Annotations
@SuppressWarnings:serial
Imports
java.awt.Color, .Component, .Container, .Dimension, .Frame, .Graphics, .Insets, .KeyboardFocusManager, .Rectangle, .Toolkit, .Window, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.io.IOException, .InputStream, .NotSerializableException, .Serial, .Serializable, java.lang.ref.ReferenceQueue, .WeakReference, java.text.ParseException, java.util.HashMap, .Locale, .Map, javax.swing.JComponent, .JMenu, .LookAndFeel, .SwingUtilities, .UIDefaults, .UIManager, javax.swing.plaf.ComponentUI, .InsetsUIResource, javax.swing.plaf.basic.BasicLookAndFeel, sun.awt.SunToolkit, sun.swing.DefaultLookup, .SwingAccessor, .SwingUtilities2, sun.swing.plaf.synth.SynthFileChooserUI

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 method, or provide your own SynthStyleFactory to setStyleFactory. Refer to the package summary for an example of loading a file, and javax.swing.plaf.synth.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.

Author
Scott Violet
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class

Field Summary

Modifier and TypeField and Description
private SynthLookAndFeel.Handler
private Map<String, Object>
defaultsMap

Map of defaults table entries.

pack-priv static final Insets
EMPTY_UIRESOURCE_INSETS

Used in a handful of places where we need an empty Insets.

private SynthStyleFactory
factory

SynthStyleFactory for the this SynthLookAndFeel.

private static SynthStyleFactory
lastFactory

The last SynthStyleFactory that was set.

private static ReferenceQueue<LookAndFeel>
private static ComponentUI
private static int

Constructor Summary

AccessConstructor and Description
public
SynthLookAndFeel()

Creates a SynthLookAndFeel.

Method Summary

Modifier and TypeMethod and Description
public static ComponentUI

Returns:

ComponentUI to use for c
createUI
(JComponent
JComponent to create the ComponentUI for
c
)

Creates the Synth look and feel ComponentUI for the passed in JComponent.

private static void
pack-priv static int
getComponentState(Component c)

Returns the component state for the specified component.

public UIDefaults

Returns:

Defaults table.
getDefaults
()

Overrides javax.swing.plaf.basic.BasicLookAndFeel.getDefaults.

Returns the defaults for this SynthLookAndFeel.

public String

Returns:

textual description of synth.
getDescription
()

Implements abstract javax.swing.LookAndFeel.getDescription.

Returns a textual description of SynthLookAndFeel.

public String

Returns:

a short string identifying this look and feel.
getID
()

Implements abstract javax.swing.LookAndFeel.getID.

Return a string that identifies this look and feel.

public String

Returns:

a short string identifying this look and feel.
getName
()

Implements abstract javax.swing.LookAndFeel.getName.

Return a short string that identifies this look and feel.

pack-priv static Insets
getPaintingInsets(SynthContext state, Insets insets)

A convenience method to return where the foreground should be painted for the Component identified by the passed in AbstractSynthContext.

public static Region

Returns:

Region corresponding to c
getRegion
(JComponent
JComponent to fetch the Region for
c
)

Returns the Region for the JComponent c.

pack-priv static ComponentUI
pack-priv static int
public static SynthStyle

Returns:

SynthStyle to use.
getStyle
(JComponent
JComponent to get the SynthStyle for
c
,
Region
Identifies the region of the specified component
region
)

Gets a SynthStyle for the specified region of the specified component.

public static SynthStyleFactory

Returns:

SynthStyleFactory
getStyleFactory
()

Returns the current SynthStyleFactory.

pack-priv static Object
getUIOfType(ComponentUI ui, Class<?> klass)

Hides javax.swing.plaf.basic.BasicLookAndFeel.getUIOfType.

Returns the ui that is of type klass, or null if one can not be found.

public void
initialize()

Overrides javax.swing.plaf.basic.BasicLookAndFeel.initialize.

Called by UIManager when this look and feel is installed.

pack-priv static boolean
public boolean

Returns:

false
isNativeLookAndFeel
()

Implements abstract javax.swing.LookAndFeel.isNativeLookAndFeel.

Returns false, SynthLookAndFeel is not a native look and feel.

public boolean

Returns:

true.
isSupportedLookAndFeel
()

Implements abstract javax.swing.LookAndFeel.isSupportedLookAndFeel.

Returns true, SynthLookAndFeel is always supported.

public void
load(InputStream
InputStream to load from
input
,
Class<?>
used to resolve any images or other resources
resourceBase
)

Loads the set of SynthStyles that will be used by this SynthLookAndFeel.

private static void
pack-priv static void
resetSelectedUI()

Clears out the selected UI that was last set in setSelectedUI.

pack-priv static void
setSelectedUI(ComponentUI uix, boolean selected, boolean focused, boolean enabled, boolean rollover)

Used by the renderers.

public static void
setStyleFactory(SynthStyleFactory
SynthStyleFactory the UIs should use.
cache
)

Sets the SynthStyleFactory that the UI classes provided by synth will use to obtain a SynthStyle.

pack-priv static boolean
shouldUpdateStyle(PropertyChangeEvent event)

Returns true if the Style should be updated in response to the specified PropertyChangeEvent.

public boolean

Returns:

whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor changed.
shouldUpdateStyleOnAncestorChanged
()

Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes.

protected boolean

Returns:

whether or not the UIs should update their styles
shouldUpdateStyleOnEvent
(PropertyChangeEvent
a PropertyChangeEvent
ev
)

Returns whether or not the UIs should update their styles when a particular event occurs.

public void
uninitialize()

Overrides javax.swing.plaf.basic.BasicLookAndFeel.uninitialize.

Called by UIManager when this look and feel is uninstalled.

pack-priv static void
update(SynthContext state, Graphics g)

A convenience method that handles painting of the background.

pack-priv static SynthStyle

Returns:

newStyle
updateStyle
(SynthContext context, SynthUI ui)

A convenience method that will reset the Style of StyleContext if necessary.

public static void
updateStyles(Component
Component to update style for.
c
)

Updates the style associated with c, and all its children.

pack-priv static void
updateSubregion(SynthContext state, Graphics g, Rectangle bounds)

A convenience method that handles painting of the background for subregions.

private static boolean

Returns:

the text antialiasing information associated to the desktop
useLAFConditions
()

Returns the antialiasing information as specified by the host desktop.

private void
Inherited from javax.swing.plaf.basic.BasicLookAndFeel:
createAudioActiongetAudioActionMapinitClassDefaultsinitComponentDefaultsinitSystemColorDefaultsloadSystemColorsplaySound

Field Detail

_handlerback to summary
private SynthLookAndFeel.Handler _handler
defaultsMapback to summary
private Map<String, Object> defaultsMap

Map of defaults table entries. This is populated via the load method.

EMPTY_UIRESOURCE_INSETSback to summary
pack-priv static final Insets EMPTY_UIRESOURCE_INSETS

Used in a handful of places where we need an empty Insets.

factoryback to summary
private SynthStyleFactory factory

SynthStyleFactory for the this SynthLookAndFeel.

lastFactoryback to summary
private static SynthStyleFactory lastFactory

The last SynthStyleFactory that was set.

queueback to summary
private static ReferenceQueue<LookAndFeel> queue
selectedUIback to summary
private static ComponentUI selectedUI
selectedUIStateValueback to summary
private static int selectedUIStateValue

Constructor Detail

SynthLookAndFeelback to summary
public SynthLookAndFeel()

Creates a SynthLookAndFeel.

For the returned SynthLookAndFeel to be useful you need to invoke load to specify the set of SynthStyles, or invoke setStyleFactory.

See Also
load, setStyleFactory

Method Detail

createUIback to summary
public static ComponentUI createUI(JComponent c)

Creates the Synth look and feel ComponentUI for the passed in JComponent.

Parameters
c:JComponent

JComponent to create the ComponentUI for

Returns:ComponentUI

ComponentUI to use for c

flushUnreferencedback to summary
private static void flushUnreferenced()
getComponentStateback to summary
pack-priv static int getComponentState(Component c)

Returns the component state for the specified component. This should only be used for Components that don't have any special state beyond that of ENABLED, DISABLED or FOCUSED. For example, buttons shouldn't call into this method.

getDefaultsback to summary
public UIDefaults getDefaults()

Overrides javax.swing.plaf.basic.BasicLookAndFeel.getDefaults.

Returns the defaults for this SynthLookAndFeel.

Returns:UIDefaults

Defaults table.

Annotations
@Override
getDescriptionback to summary
public String getDescription()

Implements abstract javax.swing.LookAndFeel.getDescription.

Returns a textual description of SynthLookAndFeel.

Returns:String

textual description of synth.

Annotations
@Override
getIDback to summary
public String getID()

Implements abstract javax.swing.LookAndFeel.getID.

Return a string that identifies this look and feel.

Returns:String

a short string identifying this look and feel.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract javax.swing.LookAndFeel.getName.

Return a short string that identifies this look and feel.

Returns:String

a short string identifying this look and feel.

Annotations
@Override
getPaintingInsetsback to summary
pack-priv static Insets getPaintingInsets(SynthContext state, Insets insets)

A convenience method to return where the foreground should be painted for the Component identified by the passed in AbstractSynthContext.

getRegionback to summary
public static Region getRegion(JComponent c)

Returns the Region for the JComponent c.

Parameters
c:JComponent

JComponent to fetch the Region for

Returns:Region

Region corresponding to c

getSelectedUIback to summary
pack-priv static ComponentUI getSelectedUI()
getSelectedUIStateback to summary
pack-priv static int getSelectedUIState()
getStyleback to summary
public static SynthStyle getStyle(JComponent c, Region region)

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

JComponent to get the SynthStyle for

region:Region

Identifies the region of the specified component

Returns:SynthStyle

SynthStyle to use.

getStyleFactoryback to summary
public static SynthStyleFactory getStyleFactory()

Returns the current SynthStyleFactory.

Returns:SynthStyleFactory

SynthStyleFactory

getUIOfTypeback to summary
pack-priv static Object getUIOfType(ComponentUI ui, Class<?> klass)

Hides javax.swing.plaf.basic.BasicLookAndFeel.getUIOfType.

Returns the ui that is of type klass, or null if one can not be found.

initializeback to summary
public void initialize()

Overrides javax.swing.plaf.basic.BasicLookAndFeel.initialize.

Called by UIManager when this look and feel is installed.

Annotations
@Override
isLeftToRightback to summary
pack-priv static boolean isLeftToRight(Component c)
isNativeLookAndFeelback to summary
public boolean isNativeLookAndFeel()

Implements abstract javax.swing.LookAndFeel.isNativeLookAndFeel.

Returns false, SynthLookAndFeel is not a native look and feel.

Returns:boolean

false

Annotations
@Override
isSupportedLookAndFeelback to summary
public boolean isSupportedLookAndFeel()

Implements abstract javax.swing.LookAndFeel.isSupportedLookAndFeel.

Returns true, SynthLookAndFeel is always supported.

Returns:boolean

true.

Annotations
@Override
loadback to summary
public void load(InputStream input, Class<?> resourceBase) throws ParseException

Loads the set of SynthStyles that will be used by this SynthLookAndFeel. resourceBase is used to resolve any path based resources, for example an Image would be resolved by resourceBase.getResource(path). Refer to Synth File Format for more information.

Parameters
input:InputStream

InputStream to load from

resourceBase:Class<?>

used to resolve any images or other resources

Exceptions
ParseException:
if there is an error in parsing
IllegalArgumentException:
if input or resourceBase is null
paintRegionback to summary
private static void paintRegion(SynthContext state, Graphics g, Rectangle bounds)
resetSelectedUIback to summary
pack-priv static void resetSelectedUI()

Clears out the selected UI that was last set in setSelectedUI.

setSelectedUIback to summary
pack-priv static void setSelectedUI(ComponentUI uix, boolean selected, boolean focused, boolean enabled, boolean rollover)

Used by the renderers. For the most part the renderers are implemented as Labels, which is problematic in so far as they are never selected. To accommodate this SynthLabelUI checks if the current UI matches that of selectedUI (which this methods sets), if it does, then a state as set by this method is returned. This provides a way for labels to have a state other than selected.

setStyleFactoryback to summary
public static void setStyleFactory(SynthStyleFactory cache)

Sets the SynthStyleFactory that the UI classes provided by synth will use to obtain a SynthStyle.

Parameters
cache:SynthStyleFactory

SynthStyleFactory the UIs should use.

shouldUpdateStyleback to summary
pack-priv static boolean shouldUpdateStyle(PropertyChangeEvent event)

Returns true if the Style should be updated in response to the specified PropertyChangeEvent. This forwards to shouldUpdateStyleOnAncestorChanged as necessary.

shouldUpdateStyleOnAncestorChangedback to summary
public boolean shouldUpdateStyleOnAncestorChanged()

Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes. A subclass that provided a SynthStyleFactory that based the return value from getStyle off the containment hierarchy would override this method to return true.

Returns:boolean

whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor changed.

shouldUpdateStyleOnEventback to summary
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev)

Returns whether or not the UIs should update their styles when a particular event occurs.

Parameters
ev:PropertyChangeEvent

a PropertyChangeEvent

Returns:boolean

whether or not the UIs should update their styles

Since
1.7
uninitializeback to summary
public void uninitialize()

Overrides javax.swing.plaf.basic.BasicLookAndFeel.uninitialize.

Called by UIManager when this look and feel is uninstalled.

Annotations
@Override
updateback to summary
pack-priv static void update(SynthContext state, Graphics g)

A convenience method that handles painting of the background. All SynthUI implementations should override update and invoke this method.

updateStyleback to summary
pack-priv static SynthStyle updateStyle(SynthContext context, SynthUI ui)

A convenience method that will reset the Style of StyleContext if necessary.

Returns:SynthStyle

newStyle

updateStylesback to summary
public static void updateStyles(Component c)

Updates the style associated with c, and all its children. This is a lighter version of SwingUtilities.updateComponentTreeUI.

Parameters
c:Component

Component to update style for.

updateSubregionback to summary
pack-priv static void updateSubregion(SynthContext state, Graphics g, Rectangle bounds)

A convenience method that handles painting of the background for subregions. All SynthUI's that have subregions should invoke this method, than paint the foreground.

useLAFConditionsback to summary
private static boolean useLAFConditions()

Returns the antialiasing information as specified by the host desktop. Antialiasing might be forced off if the desktop is GNOME and the user has set his locale to Chinese, Japanese or Korean. This is consistent with what GTK does. See com.sun.java.swing.plaf.gtk.GtkLookAndFeel for more information about CJK and antialiased fonts.

Returns:boolean

the text antialiasing information associated to the desktop

writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException
Annotations
@Serial
javax.swing.plaf.synth back to summary

private Class SynthLookAndFeel.AATextListener

extends WeakReference<LookAndFeel>
implements PropertyChangeListener
Class Inheritance
All Implemented Interfaces
java.beans.PropertyChangeListener, java.util.EventListener

Field Summary

Modifier and TypeField and Description
private String
private static boolean
updatePending

Indicates if an updateUI call is pending.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
private static synchronized boolean
isUpdatePending()

Returns true if a UI update is pending.

public void
propertyChange(PropertyChangeEvent pce)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

private static synchronized void
setUpdatePending(boolean update)

Sets whether or not an updateUI call is pending.

private static void
updateAllUIs()

Updates the UIs of all the known Frames.

protected void
private static void
updateWindowUI(Window window)

Updates the UI of the passed in window and all its children.

Field Detail

keyback to summary
private String key
updatePendingback to summary
private static boolean updatePending

Indicates if an updateUI call is pending.

Constructor Detail

AATextListenerback to summary
pack-priv AATextListener(LookAndFeel laf)

Method Detail

disposeback to summary
pack-priv void dispose()
isUpdatePendingback to summary
private static synchronized boolean isUpdatePending()

Returns true if a UI update is pending.

propertyChangeback to summary
public void propertyChange(PropertyChangeEvent pce)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
setUpdatePendingback to summary
private static synchronized void setUpdatePending(boolean update)

Sets whether or not an updateUI call is pending.

updateAllUIsback to summary
private static void updateAllUIs()

Updates the UIs of all the known Frames.

updateUIback to summary
protected void updateUI()
updateWindowUIback to summary
private static void updateWindowUI(Window window)

Updates the UI of the passed in window and all its children.

javax.swing.plaf.synth back to summary

private Class SynthLookAndFeel.Handler

extends Object
implements PropertyChangeListener
Class Inheritance
All Implemented Interfaces
java.beans.PropertyChangeListener, java.util.EventListener

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
propertyChange(PropertyChangeEvent evt)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

private void
repaintIfBackgroundsDiffer(JComponent comp)

This is a support method that will check if the background colors of the specified component differ between focused and unfocused states.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Handlerback to summary
private Handler()

Method Detail

propertyChangeback to summary
public void propertyChange(PropertyChangeEvent evt)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
repaintIfBackgroundsDifferback to summary
private void repaintIfBackgroundsDiffer(JComponent comp)

This is a support method that will check if the background colors of the specified component differ between focused and unfocused states. If the color differ the component will then repaint itself.