- java.lang.Object
-
- javax.swing.LookAndFeel
-
- javax.swing.plaf.basic.BasicLookAndFeel
-
- javax.swing.plaf.synth.SynthLookAndFeel
-
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- NimbusLookAndFeel
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 theload(java.io.InputStream, java.lang.Class<?>)
method, or provide your ownSynthStyleFactory
tosetStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)
. Refer to the package summary for an example of loading a file, andSynthStyleFactory
for an example of providing your ownSynthStyleFactory
tosetStyleFactory
.Warning: This class implements
Serializable
as a side effect of it extendingBasicLookAndFeel
. It is not intended to be serialized. An attempt to serialize it will result inNotSerializableException
.- Since:
- 1.5
-
-
Constructor Summary
Constructors Constructor and Description SynthLookAndFeel()
Creates a SynthLookAndFeel.
-
Method Summary
Methods Modifier and Type Method and Description static ComponentUI
createUI(JComponent c)
Creates the Synth look and feelComponentUI
for the passed inJComponent
.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(JComponent c)
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
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(InputStream input, Class<?> resourceBase)
Loads the set ofSynthStyle
s that will be used by thisSynthLookAndFeel
.void
load(URL url)
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
shouldUpdateStyleOnAncestorChanged()
Returns whether or not the UIs should update theirSynthStyles
from theSynthStyleFactory
when the ancestor of theJComponent
changes.protected boolean
shouldUpdateStyleOnEvent(PropertyChangeEvent ev)
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(Component c)
Updates the style associated withc
, and all its children.-
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, initClassDefaults, initComponentDefaults, initSystemColorDefaults, loadSystemColors, playSound
-
Methods inherited from class javax.swing.LookAndFeel
getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getLayoutStyle, getSupportsWindowDecorations, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninstallBorder
-
-
-
-
Constructor Detail
-
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
.
-
-
Method Detail
-
setStyleFactory
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 the UIs should use.
-
getStyleFactory
public static SynthStyleFactory getStyleFactory()
Returns the current SynthStyleFactory.- Returns:
- SynthStyleFactory
-
getStyle
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 to get the SynthStyle forregion
- Identifies the region of the specified component- Returns:
- SynthStyle to use.
-
updateStyles
public static void updateStyles(Component c)
Updates the style associated withc
, and all its children. This is a lighter version ofSwingUtilities.updateComponentTreeUI
.- Parameters:
c
- Component to update style for.
-
getRegion
public static Region getRegion(JComponent c)
Returns the Region for the JComponentc
.- Parameters:
c
- JComponent to fetch the Region for- Returns:
- Region corresponding to
c
-
createUI
public static ComponentUI createUI(JComponent c)
Creates the Synth look and feelComponentUI
for the passed inJComponent
.- Parameters:
c
- JComponent to create theComponentUI
for- Returns:
- ComponentUI to use for
c
-
load
public void load(InputStream input, Class<?> resourceBase) throws ParseException
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
-
load
public void load(URL url) throws ParseException, IOException
Loads the set ofSynthStyle
s that will be used by thisSynthLookAndFeel
. Path based resources are resolved relatively to the specifiedURL
of the style. For example anImage
would be resolved bynew 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 parsingIllegalArgumentException
- if synthSet isnull
IOException
- if synthSet cannot be opened as anInputStream
- Since:
- 1.6
-
initialize
public void initialize()
Called by UIManager when this look and feel is installed.- Overrides:
initialize
in classBasicLookAndFeel
- See Also:
LookAndFeel.uninitialize()
,UIManager.setLookAndFeel(javax.swing.LookAndFeel)
-
uninitialize
public void uninitialize()
Called by UIManager when this look and feel is uninstalled.- Overrides:
uninitialize
in classBasicLookAndFeel
- See Also:
LookAndFeel.initialize()
,UIManager.setLookAndFeel(javax.swing.LookAndFeel)
-
getDefaults
public UIDefaults getDefaults()
Returns the defaults for this SynthLookAndFeel.- Overrides:
getDefaults
in classBasicLookAndFeel
- Returns:
- Defaults table.
- See Also:
BasicLookAndFeel.initClassDefaults(javax.swing.UIDefaults)
,BasicLookAndFeel.initSystemColorDefaults(javax.swing.UIDefaults)
,BasicLookAndFeel.initComponentDefaults(javax.swing.UIDefaults)
-
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()
Returns true, SynthLookAndFeel is always supported.- Specified by:
isSupportedLookAndFeel
in classLookAndFeel
- Returns:
- true.
- See Also:
UIManager.setLookAndFeel(javax.swing.LookAndFeel)
-
isNativeLookAndFeel
public boolean isNativeLookAndFeel()
Returns false, SynthLookAndFeel is not a native look and feel.- Specified by:
isNativeLookAndFeel
in classLookAndFeel
- Returns:
- false
-
getDescription
public String getDescription()
Returns a textual description of SynthLookAndFeel.- Specified by:
getDescription
in classLookAndFeel
- Returns:
- textual description of synth.
-
getName
public String 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
public String 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
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev)
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
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/plaf/synth/SynthLookAndFeel.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.