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

public Class NimbusLookAndFeel

extends SynthLookAndFeel
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.awt.BorderLayout, .Color, .Container, .Graphics2D, .LayoutManager, javax.swing.JComponent, .UIDefaults, .UIManager, .GrayFilter, .Icon, .JToolBar, javax.swing.plaf.synth.Region, .SynthLookAndFeel, .SynthStyle, .SynthStyleFactory, .SynthIcon, javax.swing.plaf.UIResource, .BorderUIResource, .ColorUIResource, java.awt.image.BufferedImage, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.util.*, javax.swing.border.TitledBorder, sun.awt.OSInfo, sun.swing.ImageIconUIResource, sun.swing.plaf.GTKKeybindings, .WindowsKeybindings

The NimbusLookAndFeel class.

Authors
Jasper Potts, Richard Bair

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
NimbusLookAndFeel.LinkProperty

Simple Symbolic Link style UIDefaults Property

private class
NimbusLookAndFeel.NimbusProperty

Nimbus Property that looks up Nimbus keys for standard key names.

Field Summary

Modifier and TypeField and Description
private Map<String, Map<String, Object>>
private static final String[]
COMPONENT_KEYS

Set of standard region names for UIDefaults Keys

private boolean
private NimbusDefaults
defaults

A reference to the auto-generated file NimbusDefaults.

private NimbusLookAndFeel.DefaultsListener
private UIDefaults
uiDefaults

Reference to populated LAD uidefaults

Constructor Summary

AccessConstructor and Description
public
NimbusLookAndFeel()

Create a new NimbusLookAndFeel.

Method Summary

Modifier and TypeMethod and Description
private void
addDefault(String key, Object value)

pack-priv static int

Returns:

the ARGB value for a new color based on this derivation
deriveARGB
(Color
The first color
color1
,
Color
The second color
color2
,
float
The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2;
midPoint
)

Derives the ARGB value for a color based on an offset between two other colors.

public UIDefaults
getDefaults()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getDefaults.

Returns the defaults for this SynthLookAndFeel.

pack-priv Map<String, Object>
public Color

Returns:

The stored derived color
getDerivedColor
(String
The parent UIDefault key
uiDefaultParentName
,
float
The hue offset
hOffset
,
float
The saturation offset
sOffset
,
float
The brightness offset
bOffset
,
int
The alpha offset
aOffset
,
boolean
True if the derived color should be a UIResource, false if it should not be
uiResource
)

Get a derived color, derived colors are shared instances and is color value will change when its parent UIDefault color changes.

protected final Color

Returns:

The derived color
getDerivedColor
(Color
The first color
color1
,
Color
The second color
color2
,
float
The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2;
midPoint
,
boolean
True if the derived color should be a UIResource
uiResource
)

Decodes and returns a color, which is derived from an offset between two other colors.

protected final Color

Returns:

The derived color, which will be a UIResource
getDerivedColor
(Color
The first color
color1
,
Color
The second color
color2
,
float
The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2;
midPoint
)

Decodes and returns a color, which is derived from a offset between two other colors.

public String

Returns:

textual description of this look and feel.
getDescription
()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getDescription.

Returns a textual description of this look and feel.

public Icon
getDisabledIcon(JComponent component, Icon icon)

Overrides javax.swing.LookAndFeel.getDisabledIcon.

Returns an Icon with a disabled appearance.

public String

Returns:

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

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getID.

Return a string that identifies this look and feel.

public String

Returns:

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

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getName.

Return a short string that identifies this look and feel.

public static NimbusStyle

Returns:

a non-null reference to a NimbusStyle.
getStyle
(JComponent
a non-null reference to a JComponent
c
,
Region
a non-null reference to the region of the component c
r
)

Hides javax.swing.plaf.synth.SynthLookAndFeel.getStyle.

Gets the style associated with the given component and region.

public void
initialize()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.initialize.

Called by UIManager when this look and feel is installed.

pack-priv static String
public void
register(Region
The Synth Region that is being registered. Such as Button, or ScrollBarThumb, or NimbusFooUI.FOO_REGION.
region
,
String
The UIDefault prefix. For example, could be ComboBox, or if a named components, "MyComboBox", or even something like ToolBar."MyComboBox"."ComboBox.arrowButton"
prefix
)

Registers a third party component with the NimbusLookAndFeel.

pack-priv static Object
resolveToolbarConstraint(JToolBar toolbar)

Package private method which returns either BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending on the location of the toolbar in its parent.

public boolean

Returns:

true
shouldUpdateStyleOnAncestorChanged
()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.shouldUpdateStyleOnAncestorChanged.

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

protected boolean
shouldUpdateStyleOnEvent(PropertyChangeEvent ev)

Overrides javax.swing.plaf.synth.SynthLookAndFeel.shouldUpdateStyleOnEvent.

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

public void
uninitialize()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.uninitialize.

Called by UIManager when this look and feel is uninstalled.

Inherited from javax.swing.plaf.synth.SynthLookAndFeel:
createUIgetRegiongetStyleFactoryisNativeLookAndFeelisSupportedLookAndFeelloadsetStyleFactoryupdateStyles

Field Detail

compiledDefaultsback to summary
private Map<String, Map<String, Object>> compiledDefaults
COMPONENT_KEYSback to summary
private static final String[] COMPONENT_KEYS

Set of standard region names for UIDefaults Keys

defaultListenerAddedback to summary
private boolean defaultListenerAdded
defaultsback to summary
private NimbusDefaults defaults

A reference to the auto-generated file NimbusDefaults. This file contains the default mappings and values for the look and feel as specified in the visual designer.

defaultsListenerback to summary
private NimbusLookAndFeel.DefaultsListener defaultsListener
uiDefaultsback to summary
private UIDefaults uiDefaults

Reference to populated LAD uidefaults

Constructor Detail

NimbusLookAndFeelback to summary
public NimbusLookAndFeel()

Create a new NimbusLookAndFeel.

Method Detail

addDefaultback to summary
private void addDefault(String key, Object value)
deriveARGBback to summary
pack-priv static int deriveARGB(Color color1, Color color2, float midPoint)

Derives the ARGB value for a color based on an offset between two other colors.

Parameters
color1:Color

The first color

color2:Color

The second color

midPoint:float

The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2;

Returns:int

the ARGB value for a new color based on this derivation

getDefaultsback to summary
public UIDefaults getDefaults()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getDefaults.

Doc from javax.swing.plaf.synth.SynthLookAndFeel.getDefaults.

Returns the defaults for this SynthLookAndFeel.

Annotations
@Override
getDefaultsForPrefixback to summary
pack-priv Map<String, Object> getDefaultsForPrefix(String prefix)
getDerivedColorback to summary
public Color getDerivedColor(String uiDefaultParentName, float hOffset, float sOffset, float bOffset, int aOffset, boolean uiResource)

Get a derived color, derived colors are shared instances and is color value will change when its parent UIDefault color changes.

Parameters
uiDefaultParentName:String

The parent UIDefault key

hOffset:float

The hue offset

sOffset:float

The saturation offset

bOffset:float

The brightness offset

aOffset:int

The alpha offset

uiResource:boolean

True if the derived color should be a UIResource, false if it should not be

Returns:Color

The stored derived color

getDerivedColorback to summary
protected final Color getDerivedColor(Color color1, Color color2, float midPoint, boolean uiResource)

Decodes and returns a color, which is derived from an offset between two other colors.

Parameters
color1:Color

The first color

color2:Color

The second color

midPoint:float

The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2;

uiResource:boolean

True if the derived color should be a UIResource

Returns:Color

The derived color

getDerivedColorback to summary
protected final Color getDerivedColor(Color color1, Color color2, float midPoint)

Decodes and returns a color, which is derived from a offset between two other colors.

Parameters
color1:Color

The first color

color2:Color

The second color

midPoint:float

The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is color 2;

Returns:Color

The derived color, which will be a UIResource

getDescriptionback to summary
public String getDescription()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getDescription.

Returns a textual description of this look and feel.

Returns:String

textual description of this look and feel.

Annotations
@Override
getDisabledIconback to summary
public Icon getDisabledIcon(JComponent component, Icon icon)

Overrides javax.swing.LookAndFeel.getDisabledIcon.

Doc from javax.swing.LookAndFeel.getDisabledIcon.

Returns an Icon with a disabled appearance. This method is used to generate a disabled Icon when one has not been specified. For example, if you create a JButton and only specify an Icon via setIcon this method will be called to generate the disabled Icon. If null is passed as icon this method returns null.

Some look and feels might not render the disabled Icon, in which case they will ignore this.

Annotations
@Override
getIDback to summary
public String getID()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getID.

Return a string that identifies this look and feel. This String will be the unquoted String "Nimbus".

Returns:String

a short string identifying this look and feel.

Annotations
@Override
getNameback to summary
public String getName()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.getName.

Return a short string that identifies this look and feel. This String will be the unquoted String "Nimbus".

Returns:String

a short string identifying this look and feel.

Annotations
@Override
getStyleback to summary
public static NimbusStyle getStyle(JComponent c, Region r)

Hides javax.swing.plaf.synth.SynthLookAndFeel.getStyle.

Gets the style associated with the given component and region. This will never return null. If an appropriate component and region cannot be determined, then a default style is returned.

Parameters
c:JComponent

a non-null reference to a JComponent

r:Region

a non-null reference to the region of the component c

Returns:NimbusStyle

a non-null reference to a NimbusStyle.

initializeback to summary
public void initialize()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.initialize.

Called by UIManager when this look and feel is installed.

Annotations
@Override
parsePrefixback to summary
pack-priv static String parsePrefix(String key)
registerback to summary
public void register(Region region, String prefix)

Registers a third party component with the NimbusLookAndFeel.

Regions represent Components and areas within Components that act as independent painting areas. Once registered with the NimbusLookAndFeel, NimbusStyles for these Regions can be retrieved via the getStyle method.

The NimbusLookAndFeel uses a standard naming scheme for entries in the UIDefaults table. The key for each property, state, painter, and other default registered in UIDefaults for a specific Region will begin with the specified prefix

For example, suppose I had a component named JFoo. Suppose I then registered this component with the NimbusLookAndFeel in this manner:


    laf.register(NimbusFooUI.FOO_REGION, "Foo");

In this case, I could then register properties for this component with UIDefaults in the following manner:


    UIManager.put("Foo.background", new ColorUIResource(Color.BLACK));
    UIManager.put("Foo.Enabled.backgroundPainter", new FooBackgroundPainter());

It is also possible to register a named component with Nimbus. For example, suppose you wanted to style the background of a JPanel named "MyPanel" differently from other JPanels. You could accomplish this by doing the following:


    laf.register(Region.PANEL, "\"MyPanel\"");
    UIManager.put("\"MyPanel\".background", new ColorUIResource(Color.RED));
Parameters
region:Region

The Synth Region that is being registered. Such as Button, or ScrollBarThumb, or NimbusFooUI.FOO_REGION.

prefix:String

The UIDefault prefix. For example, could be ComboBox, or if a named components, "MyComboBox", or even something like ToolBar."MyComboBox"."ComboBox.arrowButton"

resolveToolbarConstraintback to summary
pack-priv static Object resolveToolbarConstraint(JToolBar toolbar)

Package private method which returns either BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending on the location of the toolbar in its parent. The toolbar might be in PAGE_START, PAGE_END, CENTER, or some other position, but will be resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar actually IS, with CENTER being NORTH. This code is used to determine where the border line should be drawn by the custom toolbar states, and also used by NimbusIcon to determine whether the handle icon needs to be shifted to look correct. Toollbars are unfortunately odd in the way these things are handled, and so this code exists to unify the logic related to toolbars so it can be shared among the static files such as NimbusIcon and generated files such as the ToolBar state classes.

shouldUpdateStyleOnAncestorChangedback to summary
public boolean shouldUpdateStyleOnAncestorChanged()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.shouldUpdateStyleOnAncestorChanged.

Doc from javax.swing.plaf.synth.SynthLookAndFeel.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

true

Annotations
@Override
shouldUpdateStyleOnEventback to summary
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev)

Overrides javax.swing.plaf.synth.SynthLookAndFeel.shouldUpdateStyleOnEvent.

Doc from javax.swing.plaf.synth.SynthLookAndFeel.shouldUpdateStyleOnEvent.

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

Overridden to return true when one of the following properties change:

  • "Nimbus.Overrides"
  • "Nimbus.Overrides.InheritDefaults"
  • "JComponent.sizeVariant"
Annotations
@Override
Since
1.7
uninitializeback to summary
public void uninitialize()

Overrides javax.swing.plaf.synth.SynthLookAndFeel.uninitialize.

Called by UIManager when this look and feel is uninstalled.

Annotations
@Override
javax.swing.plaf.nimbus back to summary

private Class NimbusLookAndFeel.DefaultsListener

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 ev)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultsListenerback to summary
private DefaultsListener()

Method Detail

propertyChangeback to summary
public void propertyChange(PropertyChangeEvent ev)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
javax.swing.plaf.nimbus back to summary

private Class NimbusLookAndFeel.LinkProperty

extends Object
implements ActiveValue, UIResource
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.UIResource, javax.swing.UIDefaults.ActiveValue

Simple Symbolic Link style UIDefaults Property

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
private
LinkProperty(String dstPropName)

Method Summary

Modifier and TypeMethod and Description
public Object
createValue(UIDefaults table)

Implements javax.swing.UIDefaults.ActiveValue.createValue.

Creates the value retrieved from the UIDefaults table.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dstPropNameback to summary
private String dstPropName

Constructor Detail

LinkPropertyback to summary
private LinkProperty(String dstPropName)

Method Detail

createValueback to summary
public Object createValue(UIDefaults table)

Implements javax.swing.UIDefaults.ActiveValue.createValue.

Doc from javax.swing.UIDefaults.ActiveValue.createValue.

Creates the value retrieved from the UIDefaults table. The object is created each time it is accessed.

Annotations
@Override
javax.swing.plaf.nimbus back to summary

private Class NimbusLookAndFeel.NimbusProperty

extends Object
implements ActiveValue, UIResource
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.UIResource, javax.swing.UIDefaults.ActiveValue

Nimbus Property that looks up Nimbus keys for standard key names. For example "Button.background" --> "Button[Enabled].background"

Field Summary

Modifier and TypeField and Description
private boolean
private String
private String
private String

Constructor Summary

AccessConstructor and Description
private
NimbusProperty(String prefix, String suffix)

private
NimbusProperty(String prefix, String state, String suffix)

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the created Object
createValue
(UIDefaults
a UIDefaults table
table
)

Implements javax.swing.UIDefaults.ActiveValue.createValue.

Creates the value retrieved from the UIDefaults table.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isFontback to summary
private boolean isFont
prefixback to summary
private String prefix
stateback to summary
private String state
suffixback to summary
private String suffix

Constructor Detail

NimbusPropertyback to summary
private NimbusProperty(String prefix, String suffix)
NimbusPropertyback to summary
private NimbusProperty(String prefix, String state, String suffix)

Method Detail

createValueback to summary
public Object createValue(UIDefaults table)

Implements javax.swing.UIDefaults.ActiveValue.createValue.

Creates the value retrieved from the UIDefaults table. The object is created each time it is accessed.

Parameters
table:UIDefaults

a UIDefaults table

Returns:Object

the created Object

Annotations
@Override