Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ButtonUI
javax.swing.plaf.basic.BasicButtonUI
public class BasicButtonUI
extends ButtonUI
JButton
component.
Field Summary | |
protected int |
|
protected int |
|
Method Summary | |
protected void |
|
protected BasicButtonListener |
|
static ComponentUI |
|
int |
|
Dimension |
|
Dimension |
|
Dimension |
|
protected String |
|
protected int |
|
protected void |
|
protected void | |
protected void |
|
void |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void | |
protected void |
|
void |
|
Methods inherited from class javax.swing.plaf.ComponentUI | |
contains , createUI , getAccessibleChild , getAccessibleChildrenCount , getMaximumSize , getMinimumSize , getPreferredSize , installUI , paint , uninstallUI , update |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
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.
protected void clearTextShiftOffset()
Sets the text shift offset to zero.
- See Also:
setTextShiftOffset()
protected BasicButtonListener createButtonListener(AbstractButton b)
Creates and returns a new instance ofBasicButtonListener
. This method provides a hook to make it easy for subclasses to install a different listener.
- Parameters:
b
- the button.
- Returns:
- A new listener.
public static ComponentUI createUI(JComponent c)
Factory method to create an instance of BasicButtonUI for a givenJComponent
, which should be anAbstractButton
.
- Overrides:
- createUI in interface ComponentUI
- Parameters:
c
- The component.
- Returns:
- A new UI capable of drawing the component
public int getDefaultTextIconGap(AbstractButton b)
Returns the default gap between the button's text and icon (in pixels).
- Parameters:
b
- the button (ignored).
- Returns:
- The gap.
public Dimension getMaximumSize(JComponent c)
Calculates the maximum size for the specified component.
- Overrides:
- getMaximumSize in interface ComponentUI
- Parameters:
c
- the component for which to compute the maximum size
- Returns:
- the maximum size for the specified component
public Dimension getMinimumSize(JComponent c)
Calculates the minimum size for the specified component.
- Overrides:
- getMinimumSize in interface ComponentUI
- Parameters:
c
- the component for which to compute the minimum size
- Returns:
- the minimum size for the specified component
public Dimension getPreferredSize(JComponent c)
Calculate the preferred size of this component, by delegating toBasicGraphicsUtils.getPreferredButtonSize(AbstractButton,int)
.
- Overrides:
- getPreferredSize in interface ComponentUI
- Parameters:
c
- The component to measure
- Returns:
- The preferred dimensions of the component
protected String getPropertyPrefix()
Returns the prefix for the UI defaults property for this UI class. This is 'Button' for this class.
- Returns:
- the prefix for the UI defaults property
protected int getTextShiftOffset()
Returns the text shift offset.
- Returns:
- The text shift offset.
- See Also:
clearTextShiftOffset()
,setTextShiftOffset()
protected void installDefaults(AbstractButton b)
Installs the default settings.
- Parameters:
b
- the button (null
not permitted).
protected void installListeners(AbstractButton b)
Installs listeners for the button.
- Parameters:
b
- the button (null
not permitted).
public void installUI(JComponent c)
Install the BasicButtonUI as the UI for a particular component. This means registering all the UI's listeners with the component, and setting any properties of the button which are particular to this look and feel.
- Overrides:
- installUI in interface ComponentUI
- Parameters:
c
- The component to install the UI into
public void paint(Graphics g, JComponent c)
Paint the component, which is anAbstractButton
, according to its current state.
- Overrides:
- paint in interface ComponentUI
- Parameters:
g
- The graphics context to paint withc
- The component to paint the state of
protected void paintButtonPressed(Graphics g, AbstractButton b)
Paints the background area of anAbstractButton
in the pressed state. This means filling the supplied area with a darker than normal background.
- Parameters:
g
- The graphics context to paint withb
- The button to paint the state of
protected void paintFocus(Graphics g, AbstractButton b, Rectangle vr, Rectangle tr, Rectangle ir)
Paint any focus decoration thisJComponent
might have. The component, which in this case will be anAbstractButton
, should only have focus decoration painted if it has the focus, and its "focusPainted" property istrue
.
- Parameters:
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 rectangle
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect)
Paint the icon for this component. Depending on the state of the component and the availability of the button's various icon properties, this might mean painting one of several different icons.
- Parameters:
g
- Graphics context to paint withc
- Component to paint the icon oficonRect
- Rectangle in which the icon should be painted
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text)
Paints the "text" property of anAbstractButton
.
- Parameters:
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
- Since:
- 1.4
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text)
Paints the "text" property of anAbstractButton
.
- Parameters:
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 paint
protected void setTextShiftOffset()
Sets the text shift offset to the value indefaultTextShiftOffset
.
- See Also:
clearTextShiftOffset()
protected void uninstallDefaults(AbstractButton b)
Removes the defaults added byinstallDefaults(AbstractButton)
.
- Parameters:
b
- the button (null
not permitted).
protected void uninstallListeners(AbstractButton b)
Uninstalls listeners for the button.
- Parameters:
b
- the button (null
not permitted).
public void uninstallUI(JComponent c)
Uninstalls the UI from the component.
- Overrides:
- uninstallUI in interface ComponentUI
- Parameters:
c
- the component from which to uninstall the UI