|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.plaf.ComponentUI
javax.swing.plaf.ButtonUI
javax.swing.plaf.basic.BasicButtonUI
public class BasicButtonUI
A UI delegate for the JButton
component.
Field Summary | |
---|---|
protected int |
defaultTextIconGap
A constant used to pad out elements in the button's layout and preferred size calculations. |
protected int |
defaultTextShiftOffset
A constant added to the defaultTextIconGap to adjust the text within this particular button. |
Constructor Summary | |
---|---|
BasicButtonUI()
|
Method Summary | |
---|---|
protected void |
clearTextShiftOffset()
Sets the text shift offset to zero. |
protected BasicButtonListener |
createButtonListener(AbstractButton b)
Creates and returns a new instance of BasicButtonListener . |
static ComponentUI |
createUI(JComponent c)
Factory method to create an instance of BasicButtonUI for a given JComponent , which should be an AbstractButton . |
int |
getDefaultTextIconGap(AbstractButton b)
Returns the default gap between the button's text and icon (in pixels). |
Dimension |
getMaximumSize(JComponent c)
Calculates the maximum size for the specified component. |
Dimension |
getMinimumSize(JComponent c)
Calculates the minimum size for the specified component. |
Dimension |
getPreferredSize(JComponent c)
Calculate the preferred size of this component, by delegating to BasicGraphicsUtils.getPreferredButtonSize(javax.swing.AbstractButton, int) . |
protected String |
getPropertyPrefix()
Returns the prefix for the UI defaults property for this UI class. |
protected int |
getTextShiftOffset()
Returns the text shift offset. |
protected void |
installDefaults(AbstractButton b)
Installs the default settings. |
protected void |
installKeyboardActions(AbstractButton b)
|
protected void |
installListeners(AbstractButton b)
Installs listeners for the button. |
void |
installUI(JComponent c)
Install the BasicButtonUI as the UI for a particular component. |
void |
paint(Graphics g,
JComponent c)
Paint the component, which is an AbstractButton , according to
its current state. |
protected void |
paintButtonPressed(Graphics g,
AbstractButton b)
Paints the background area of an AbstractButton in the pressed
state. |
protected void |
paintFocus(Graphics g,
AbstractButton b,
Rectangle vr,
Rectangle tr,
Rectangle ir)
Paint any focus decoration this JComponent might have. |
protected void |
paintIcon(Graphics g,
JComponent c,
Rectangle iconRect)
Paint the icon for this component. |
protected void |
paintText(Graphics g,
AbstractButton b,
Rectangle textRect,
String text)
Paints the "text" property of an AbstractButton . |
protected void |
paintText(Graphics g,
JComponent c,
Rectangle textRect,
String text)
Paints the "text" property of an AbstractButton . |
protected void |
setTextShiftOffset()
Sets the text shift offset to the value in defaultTextShiftOffset . |
protected void |
uninstallDefaults(AbstractButton b)
Removes the defaults added by installDefaults(AbstractButton) . |
protected void |
uninstallKeyboardActions(AbstractButton b)
|
protected void |
uninstallListeners(AbstractButton b)
Uninstalls listeners for the button. |
void |
uninstallUI(JComponent c)
Uninstalls the UI from the component. |
Methods inherited from class javax.swing.plaf.ComponentUI |
---|
contains, getAccessibleChild, getAccessibleChildrenCount, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int defaultTextIconGap
protected int defaultTextShiftOffset
Constructor Detail |
---|
public BasicButtonUI()
Method Detail |
---|
public static ComponentUI createUI(JComponent c)
JComponent
, which should be an AbstractButton
.
c
- The component.
public int getDefaultTextIconGap(AbstractButton b)
b
- the button (ignored).
protected void clearTextShiftOffset()
setTextShiftOffset()
protected int getTextShiftOffset()
clearTextShiftOffset()
,
setTextShiftOffset()
protected void setTextShiftOffset()
defaultTextShiftOffset
.
clearTextShiftOffset()
protected String getPropertyPrefix()
protected void installDefaults(AbstractButton b)
b
- the button (null
not permitted).protected void uninstallDefaults(AbstractButton b)
installDefaults(AbstractButton)
.
b
- the button (null
not permitted).protected BasicButtonListener createButtonListener(AbstractButton b)
BasicButtonListener
. This
method provides a hook to make it easy for subclasses to install a
different listener.
b
- the button.
protected void installListeners(AbstractButton b)
b
- the button (null
not permitted).protected void uninstallListeners(AbstractButton b)
b
- the button (null
not permitted).protected void installKeyboardActions(AbstractButton b)
protected void uninstallKeyboardActions(AbstractButton b)
public void installUI(JComponent c)
installUI
in class ComponentUI
c
- The component to install the UI intoComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
uninstallUI
in class ComponentUI
c
- the component from which to uninstall the UIComponentUI.installUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public Dimension getMinimumSize(JComponent c)
getMinimumSize
in class ComponentUI
c
- the component for which to compute the minimum size
public Dimension getMaximumSize(JComponent c)
getMaximumSize
in class ComponentUI
c
- the component for which to compute the maximum size
public Dimension getPreferredSize(JComponent c)
BasicGraphicsUtils.getPreferredButtonSize(javax.swing.AbstractButton, int)
.
getPreferredSize
in class ComponentUI
c
- The component to measure
public void paint(Graphics g, JComponent c)
AbstractButton
, according to
its current state.
paint
in class ComponentUI
g
- The graphics context to paint withc
- The component to paint the state ofprotected void paintFocus(Graphics g, AbstractButton b, Rectangle vr, Rectangle tr, Rectangle ir)
JComponent
might have. The
component, which in this case will be an AbstractButton
,
should only have focus decoration painted if it has the focus, and its
"focusPainted" property is true
.
g
- Graphics context to paint withb
- Button to paint the focus ofvr
- Visible rectangle, the area in which to painttr
- Text rectangle, contained in visible rectangleir
- Icon rectangle, contained in visible rectangleAbstractButton.isFocusPainted()
,
Component.hasFocus()
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect)
g
- Graphics context to paint withc
- Component to paint the icon oficonRect
- Rectangle in which the icon should be paintedprotected void paintButtonPressed(Graphics g, AbstractButton b)
AbstractButton
in the pressed
state. This means filling the supplied area with a darker than normal
background.
g
- The graphics context to paint withb
- The button to paint the state ofprotected void paintText(Graphics g, JComponent c, Rectangle textRect, String text)
AbstractButton
.
g
- The graphics context to paint withc
- The component to paint the state oftextRect
- The area in which to paint the texttext
- The text to paintprotected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text)
AbstractButton
.
g
- The graphics context to paint withb
- The button to paint the state oftextRect
- The area in which to paint the texttext
- The text to paint
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |