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

public Class SynthButtonUI

extends BasicButtonUI
implements PropertyChangeListener, SynthUI
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.synth.SynthUI, javax.swing.plaf.synth.SynthConstants, java.beans.PropertyChangeListener, java.util.EventListener
Known Direct Subclasses
javax.swing.plaf.synth.SynthToggleButtonUI, javax.swing.plaf.synth.SynthArrowButton.SynthArrowButtonUI
Imports
javax.swing.*, java.awt.*, java.beans.*, javax.swing.plaf.*, javax.swing.plaf.basic.BasicButtonUI, .BasicHTML, javax.swing.text.View

Provides the Synth L&F UI delegate for javax.swing.JButton.
Author
Scott Violet
Since
1.7

Field Summary

Modifier and TypeField and Description
private SynthStyle
Inherited from javax.swing.plaf.basic.BasicButtonUI:
defaultTextIconGapdefaultTextShiftOffset

Constructor Summary

AccessConstructor and Description
public
SynthButtonUI()

Constructs a SynthButtonUI.

Method Summary

Modifier and TypeMethod and Description
public static ComponentUI

Returns:

the UI object
createUI
(JComponent
component to create UI object for
c
)

Hides javax.swing.plaf.basic.BasicButtonUI.createUI.

Creates a new UI object for the given component.

public int
getBaseline(JComponent c, int width, int height)

Overrides javax.swing.plaf.basic.BasicButtonUI.getBaseline.

Returns the baseline.

private int
getComponentState(JComponent c)

Returns the current state of the passed in AbstractButton.

public SynthContext
getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

pack-priv SynthContext
getContext(JComponent c, int state)

protected Icon

Returns:

default icon
getDefaultIcon
(AbstractButton
button the icon is associated with
b
)

Returns the default icon.

private Icon
protected Icon

Returns:

an icon
getIcon
(AbstractButton
button the icon is associated with
b
)

Returns the Icon to use for painting the button.

private Icon
getIcon(AbstractButton
button
b
,
Icon
icon returned from the button for the specific state
specificIcon
,
Icon
fallback icon
defaultIcon
,
int
the synth state of the button
state
)

This method will return the icon that should be used for a button.

public Dimension
getMaximumSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.getMaximumSize.

Returns the specified component's maximum size appropriate for the look and feel.

public Dimension
getMinimumSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.getMinimumSize.

Returns the specified component's minimum size appropriate for the look and feel.

public Dimension
getPreferredSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.getPreferredSize.

Returns the specified component's preferred size appropriate for the look and feel.

private Icon
private Icon
private Icon
protected Icon

Returns:

the Icon used in calculating the preferred/minimum/maximum size.
getSizingIcon
(AbstractButton
specifies the AbstractButton used when calculating the preferred/minimum/maximum size.
b
)

Returns the Icon used in calculating the preferred/minimum/maximum size.

private Icon
getSpecificIcon(AbstractButton b, Icon specificSelectedIcon, Icon specificIcon, Icon defaultIcon, int state)

private Icon
private Icon
getSynthIcon(AbstractButton b, int synthConstant)

private int
getTextShiftOffset(SynthContext state)

Returns the amount to shift the text/icon when painting.

protected void
protected void
public void
paint(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.basic.BasicButtonUI.paint.

Paints the specified component according to the Look and Feel.

protected void
paint(SynthContext
context for the component being painted
context
,
Graphics
the Graphics object used for painting
g
)

Paints the specified component.

pack-priv void
public void
paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

public void
propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

protected void
protected void
public void
update(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component.

pack-priv void
Inherited from javax.swing.plaf.basic.BasicButtonUI:
clearTextShiftOffsetcreateButtonListenergetBaselineResizeBehaviorgetDefaultTextIconGapgetPropertyPrefixgetTextShiftOffsetinstallKeyboardActionsinstallUIpaintButtonPressedpaintFocuspaintIconpaintTextpaintTextsetTextShiftOffsetuninstallKeyboardActionsuninstallUI

Field Detail

styleback to summary
private SynthStyle style

Constructor Detail

SynthButtonUIback to summary
public SynthButtonUI()

Constructs a SynthButtonUI.

Method Detail

createUIback to summary
public static ComponentUI createUI(JComponent c)

Hides javax.swing.plaf.basic.BasicButtonUI.createUI.

Creates a new UI object for the given component.

Parameters
c:JComponent

component to create UI object for

Returns:ComponentUI

the UI object

getBaselineback to summary
public int getBaseline(JComponent c, int width, int height)

Overrides javax.swing.plaf.basic.BasicButtonUI.getBaseline.

Doc from javax.swing.plaf.basic.BasicButtonUI.getBaseline.

Returns the baseline.

Annotations
@Override
getComponentStateback to summary
private int getComponentState(JComponent c)

Returns the current state of the passed in AbstractButton.

getContextback to summary
public SynthContext getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Doc from javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

Annotations
@Override
getContextback to summary
pack-priv SynthContext getContext(JComponent c, int state)
getDefaultIconback to summary
protected Icon getDefaultIcon(AbstractButton b)

Returns the default icon. This should not callback to the JComponent.

Parameters
b:AbstractButton

button the icon is associated with

Returns:Icon

default icon

getEnabledIconback to summary
private Icon getEnabledIcon(AbstractButton b, Icon defaultIcon)
getIconback to summary
protected Icon getIcon(AbstractButton b)

Returns the Icon to use for painting the button. The icon is chosen with respect to the current state of the button.

Parameters
b:AbstractButton

button the icon is associated with

Returns:Icon

an icon

getIconback to summary
private Icon getIcon(AbstractButton b, Icon specificIcon, Icon defaultIcon, int state)

This method will return the icon that should be used for a button. We only want to use the synth icon defined by the style if the specific icon has not been defined for the button state and the backup icon is a UIResource (we set it, not the developer) or null.

Parameters
b:AbstractButton

button

specificIcon:Icon

icon returned from the button for the specific state

defaultIcon:Icon

fallback icon

state:int

the synth state of the button

getMaximumSizeback to summary
public Dimension getMaximumSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.getMaximumSize.

Doc from javax.swing.plaf.ComponentUI.getMaximumSize.

Returns the specified component's maximum size appropriate for the look and feel. If null is returned, the maximum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize and returns that value.

Annotations
@Override
getMinimumSizeback to summary
public Dimension getMinimumSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.getMinimumSize.

Doc from javax.swing.plaf.ComponentUI.getMinimumSize.

Returns the specified component's minimum size appropriate for the look and feel. If null is returned, the minimum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize and returns that value.

Annotations
@Override
getPreferredSizeback to summary
public Dimension getPreferredSize(JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.getPreferredSize.

Doc from javax.swing.plaf.ComponentUI.getPreferredSize.

Returns the specified component's preferred size appropriate for the look and feel. If null is returned, the preferred size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method returns null.

Annotations
@Override
getPressedIconback to summary
private Icon getPressedIcon(AbstractButton b, Icon defaultIcon)
getRolloverIconback to summary
private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon)
getSelectedIconback to summary
private Icon getSelectedIcon(AbstractButton b, Icon defaultIcon)
getSizingIconback to summary
protected Icon getSizingIcon(AbstractButton b)

Returns the Icon used in calculating the preferred/minimum/maximum size.

Parameters
b:AbstractButton

specifies the AbstractButton used when calculating the preferred/minimum/maximum size.

Returns:Icon

the Icon used in calculating the preferred/minimum/maximum size.

getSpecificIconback to summary
private Icon getSpecificIcon(AbstractButton b, Icon specificSelectedIcon, Icon specificIcon, Icon defaultIcon, int state)
getSynthDisabledIconback to summary
private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon)
getSynthIconback to summary
private Icon getSynthIcon(AbstractButton b, int synthConstant)
getTextShiftOffsetback to summary
private int getTextShiftOffset(SynthContext state)

Returns the amount to shift the text/icon when painting.

installDefaultsback to summary
protected void installDefaults(AbstractButton b)

Overrides javax.swing.plaf.basic.BasicButtonUI.installDefaults.

Doc from javax.swing.plaf.basic.BasicButtonUI.installDefaults.

Installs default properties.

Annotations
@Override
installListenersback to summary
protected void installListeners(AbstractButton b)

Overrides javax.swing.plaf.basic.BasicButtonUI.installListeners.

Doc from javax.swing.plaf.basic.BasicButtonUI.installListeners.

Registers listeners.

Annotations
@Override
paintback to summary
public void paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.basic.BasicButtonUI.paint.

Paints the specified component according to the Look and Feel.

This method is not used by Synth Look and Feel. Painting is handled by the paint(SynthContext, Graphics) method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
paintback to summary
protected void paint(SynthContext context, Graphics g)

Paints the specified component.

Parameters
context:SynthContext

context for the component being painted

g:Graphics

the Graphics object used for painting

See Also
update(Graphics, JComponent)
paintBackgroundback to summary
pack-priv void paintBackground(SynthContext context, Graphics g, JComponent c)
paintBorderback to summary
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Doc from javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

Annotations
@Override
propertyChangeback to summary
public void propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
uninstallDefaultsback to summary
protected void uninstallDefaults(AbstractButton b)

Overrides javax.swing.plaf.basic.BasicButtonUI.uninstallDefaults.

Doc from javax.swing.plaf.basic.BasicButtonUI.uninstallDefaults.

Uninstalls default properties.

Annotations
@Override
uninstallListenersback to summary
protected void uninstallListeners(AbstractButton b)

Overrides javax.swing.plaf.basic.BasicButtonUI.uninstallListeners.

Doc from javax.swing.plaf.basic.BasicButtonUI.uninstallListeners.

Unregisters listeners.

Annotations
@Override
updateback to summary
public void update(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls the paint(SynthContext, Graphics) method.

In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the paint method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
updateStyleback to summary
pack-priv void updateStyle(AbstractButton b)