public class SynthLookAndFeel extends BasicLookAndFeel
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(java.io.InputStream, java.lang.Class<?>)
method, or provide your own SynthStyleFactory
to setStyleFactory(javax.swing.plaf.synth.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
.
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
.
public SynthLookAndFeel()
Creates a SynthLookAndFeel.
For the returned SynthLookAndFeel
to be useful you need to invoke load
to specify the set of SynthStyle
s, or invoke setStyleFactory
.
load(java.io.InputStream, java.lang.Class<?>)
, setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)
public static void setStyleFactory(SynthStyleFactory cache)
Sets the SynthStyleFactory that the UI classes provided by synth will use to obtain a SynthStyle.
cache
- SynthStyleFactory the UIs should use.public static SynthStyleFactory getStyleFactory()
Returns the current SynthStyleFactory.
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.
c
- JComponent to get the SynthStyle forregion
- Identifies the region of the specified componentpublic static void updateStyles(Component c)
Updates the style associated with c
, and all its children. This is a lighter version of SwingUtilities.updateComponentTreeUI
.
c
- Component to update style for.public static Region getRegion(JComponent c)
Returns the Region for the JComponent c
.
c
- JComponent to fetch the Region forc
public static ComponentUI createUI(JComponent c)
Creates the Synth look and feel ComponentUI
for the passed in JComponent
.
c
- JComponent to create the ComponentUI
forc
public void load(InputStream input, Class<?> resourceBase) throws ParseException
Loads the set of SynthStyle
s 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.
input
- InputStream to load fromresourceBase
- used to resolve any images or other resourcesParseException
- if there is an error in parsingIllegalArgumentException
- if input or resourceBase is null
public void load(URL url) throws ParseException, IOException
Loads the set of SynthStyle
s that will be used by this SynthLookAndFeel
. Path based resources are resolved relatively to the specified URL
of the style. For example an Image
would be resolved by new URL(synthFile, path)
. Refer to Synth File Format for more information.
url
- the URL
to load the set of SynthStyle
fromParseException
- if there is an error in parsingIllegalArgumentException
- if synthSet is null
IOException
- if synthSet cannot be opened as an InputStream
public void initialize()
Called by UIManager when this look and feel is installed.
initialize
in class BasicLookAndFeel
LookAndFeel.uninitialize()
, UIManager.setLookAndFeel(javax.swing.LookAndFeel)
public void uninitialize()
Called by UIManager when this look and feel is uninstalled.
uninitialize
in class BasicLookAndFeel
LookAndFeel.initialize()
, UIManager.setLookAndFeel(javax.swing.LookAndFeel)
public UIDefaults getDefaults()
Returns the defaults for this SynthLookAndFeel.
getDefaults
in class BasicLookAndFeel
BasicLookAndFeel.initClassDefaults(javax.swing.UIDefaults)
, BasicLookAndFeel.initSystemColorDefaults(javax.swing.UIDefaults)
, BasicLookAndFeel.initComponentDefaults(javax.swing.UIDefaults)
public boolean isSupportedLookAndFeel()
Returns true, SynthLookAndFeel is always supported.
isSupportedLookAndFeel
in class LookAndFeel
UIManager.setLookAndFeel(javax.swing.LookAndFeel)
public boolean isNativeLookAndFeel()
Returns false, SynthLookAndFeel is not a native look and feel.
isNativeLookAndFeel
in class LookAndFeel
public String getDescription()
Returns a textual description of SynthLookAndFeel.
getDescription
in class LookAndFeel
public String getName()
Return a short string that identifies this look and feel.
getName
in class LookAndFeel
public String getID()
Return a string that identifies this look and feel.
getID
in class LookAndFeel
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.
SynthStyles
from the SynthStyleFactory
when the ancestor changed.protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev)
Returns whether or not the UIs should update their styles when a particular event occurs.
ev
- a PropertyChangeEvent
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.