Class SynthLookAndFeel
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NimbusLookAndFeel
public class SynthLookAndFeel extends BasicLookAndFeel
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
. 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
Constructor | Description |
---|---|
SynthLookAndFeel() |
Creates a SynthLookAndFeel. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
static ComponentUI |
createUI |
Creates the Synth look and feel ComponentUI for the passed in JComponent . |
UIDefaults |
getDefaults() |
Returns the defaults for this SynthLookAndFeel. |
String |
getDescription() |
Returns a textual description of SynthLookAndFeel. |
String |
getID() |
Return a string that identifies this look and feel. |
String |
getName() |
Return a short string that identifies this look and feel. |
static Region |
getRegion |
Returns the Region for the JComponent c . |
static SynthStyle |
getStyle |
Gets a SynthStyle for the specified region of the specified component. |
static SynthStyleFactory |
getStyleFactory() |
Returns the current SynthStyleFactory. |
void |
initialize() |
Called by UIManager when this look and feel is installed. |
boolean |
isNativeLookAndFeel() |
Returns false, SynthLookAndFeel is not a native look and feel. |
boolean |
isSupportedLookAndFeel() |
Returns true, SynthLookAndFeel is always supported. |
void |
load |
Loads the set of SynthStyle s that will be used by this SynthLookAndFeel . |
void |
load |
Loads the set of SynthStyle s that will be used by this SynthLookAndFeel . |
static void |
setStyleFactory |
Sets the SynthStyleFactory that the UI classes provided by synth will use to obtain a SynthStyle. |
boolean |
shouldUpdateStyleOnAncestorChanged() |
Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes. |
protected boolean |
shouldUpdateStyleOnEvent |
Returns whether or not the UIs should update their styles when a particular event occurs. |
void |
uninitialize() |
Called by UIManager when this look and feel is uninstalled. |
static void |
updateStyles |
Updates the style associated with c , and all its children. |
Methods declared in class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, initClassDefaults, initComponentDefaults, initSystemColorDefaults, loadSystemColors, playSound
Methods declared in class javax.swing.LookAndFeel
getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getLayoutStyle, getSupportsWindowDecorations, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninstallBorder
Constructor Details
SynthLookAndFeel
public SynthLookAndFeel()
For the returned SynthLookAndFeel
to be useful you need to invoke load
to specify the set of SynthStyle
s, or invoke setStyleFactory
.
Method Details
setStyleFactory
public static void setStyleFactory(SynthStyleFactory cache)
- Parameters:
-
cache
- SynthStyleFactory the UIs should use.
getStyleFactory
public static SynthStyleFactory getStyleFactory()
- Returns:
- SynthStyleFactory
getStyle
public static SynthStyle getStyle(JComponent c, Region region)
- Parameters:
-
c
- JComponent to get the SynthStyle for -
region
- Identifies the region of the specified component - Returns:
- SynthStyle to use.
updateStyles
public static void updateStyles(Component c)
c
, and all its children. This is a lighter version of SwingUtilities.updateComponentTreeUI
.- Parameters:
-
c
- Component to update style for.
getRegion
public static Region getRegion(JComponent c)
c
.- Parameters:
-
c
- JComponent to fetch the Region for - Returns:
- Region corresponding to
c
createUI
public static ComponentUI createUI(JComponent c)
ComponentUI
for the passed in JComponent
.- Parameters:
-
c
- JComponent to create theComponentUI
for - Returns:
- ComponentUI to use for
c
load
public void load(InputStream input, Class<?> resourceBase) throws ParseException
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.- Parameters:
-
input
- InputStream to load from -
resourceBase
- used to resolve any images or other resources - Throws:
-
ParseException
- if there is an error in parsing -
IllegalArgumentException
- if input or resourceBase isnull
load
public void load(URL url) throws ParseException, IOException
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.- Parameters:
-
url
- theURL
to load the set ofSynthStyle
from - Throws:
-
ParseException
- if there is an error in parsing -
IllegalArgumentException
- if synthSet isnull
-
IOException
- if synthSet cannot be opened as anInputStream
- Since:
- 1.6
initialize
public void initialize()
- Overrides:
-
initialize
in classLookAndFeel
- See Also:
uninitialize
public void uninitialize()
- Overrides:
-
uninitialize
in classLookAndFeel
- See Also:
getDefaults
public UIDefaults getDefaults()
- Overrides:
-
getDefaults
in classBasicLookAndFeel
- Returns:
- Defaults table.
- See Also:
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()
- Specified by:
-
isSupportedLookAndFeel
in classLookAndFeel
- Returns:
- true.
- See Also:
isNativeLookAndFeel
public boolean isNativeLookAndFeel()
- Specified by:
-
isNativeLookAndFeel
in classLookAndFeel
- Returns:
- false
getDescription
public String getDescription()
- Specified by:
-
getDescription
in classLookAndFeel
- Returns:
- textual description of synth.
getName
public String getName()
- Specified by:
-
getName
in classLookAndFeel
- Returns:
- a short string identifying this look and feel.
getID
public String getID()
- Specified by:
-
getID
in classLookAndFeel
- Returns:
- a short string identifying this look and feel.
shouldUpdateStyleOnAncestorChanged
public boolean shouldUpdateStyleOnAncestorChanged()
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:
- whether or not the UIs should update their
SynthStyles
from theSynthStyleFactory
when the ancestor changed.
shouldUpdateStyleOnEvent
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev)
- Parameters:
-
ev
- aPropertyChangeEvent
- Returns:
- whether or not the UIs should update their styles
- Since:
- 1.7
© 1993, 2021, 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.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/plaf/synth/SynthLookAndFeel.html