|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--dog.gui.DComponent | +--dog.gui.DCheckbox | +--dog.gui.DButton
A multiline button with an optional icon.
The button can be in one of two states: up or down. Normally it is only down while the user is pressing the button. This generates an action event when the button is released. By setting the button to sticky you change the behaviour of the button to that of a checkbox: the button stays down when the user releases the mouse, and will only be released when the user presses the button again. The latter behaviour generates item events (a state change of 1 indicates that the button is down, and 0 indicates that is it up).
The behaviour of buttons in sticky mode is controlled by setting a DCheckboxGroup manager. This handles the dependencies between a set of buttons and checkboxes.
You can specify a label and/or an icon for the button. If a label is specified without an icon, or an icon without a label, it is centred on the button. If both an icon and label are specified, the icon is drawn to the left, and the label is left-aligned against the right-hand edge of the icon. The icon is scaled to fit in the button if it is too large.
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
protected boolean |
bold
Whether to use a bold font for the button label. |
protected java.awt.Image |
icon
The button icon. |
static int |
LEFT
The left alignment. |
static int |
RIGHT
The right alignment. |
protected boolean |
sticky
The button stickiness. |
Fields inherited from class dog.gui.DCheckbox |
align, command, down, focus, group, label, value |
Fields inherited from class dog.gui.DComponent |
CENTER, CENTER_TILE, changes, EAST, INTEGER_TILE, MAXIMIZE, MAXIMIZE_ASPECT, MAXIMIZE_HORIZONTAL, MAXIMIZE_VERTICAL, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, TILE, tooltip, WEST |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
DButton()
Constructs a button with no label or icon. |
|
DButton(java.awt.Image icon)
Constructs a button with the specified icon and no label. |
|
DButton(java.awt.Image icon,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified icon, default value and group, and no label. |
|
DButton(java.awt.Image icon,
int align)
Constructs a button with the specified icon and alignment and no label. |
|
DButton(java.awt.Image icon,
int align,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified icon, alignment, default value and group, and no label. |
|
DButton(java.lang.String label)
Constructs a button with the specified label. |
|
DButton(java.lang.String label,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified label, default value and group. |
|
DButton(java.lang.String label,
DCheckboxGroup group)
Constructs a sticky button with the specified label and group. |
|
DButton(java.lang.String label,
java.awt.Image icon)
Constructs a button with the specified label and icon. |
|
DButton(java.lang.String label,
java.awt.Image icon,
int align)
Constructs a button with the specified label, icon, and alignment. |
|
DButton(java.lang.String label,
java.awt.Image icon,
int align,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified label, icon, alignment, default value and group. |
|
DButton(java.lang.String label,
int align)
Constructs a button with the specified label and alignment. |
|
DButton(java.lang.String label,
int align,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified label, alignment, default value and group. |
|
DButton(java.lang.String label,
java.net.URL icon)
Constructs a button with the specified label and icon. |
|
DButton(java.lang.String label,
java.net.URL icon,
int align)
Constructs a button with the specified label, icon, and alignment. |
|
DButton(java.lang.String label,
java.net.URL icon,
int align,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified label, icon, alignment, default value and group. |
|
DButton(java.net.URL icon)
Constructs a button with the specified icon and no label. |
|
DButton(java.net.URL icon,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified icon, default value and group, and no label. |
|
DButton(java.net.URL icon,
int align)
Constructs a button with the specified icon and alignment and no label. |
|
DButton(java.net.URL icon,
int align,
boolean value,
DCheckboxGroup group)
Constructs a sticky button with the specified icon, alignment, default value and group, and no label. |
Method Summary | |
int |
getAlign()
Returns the alignment of the checkbox (LEFT, RIGHT, or CENTER). |
java.awt.Image |
getIcon()
Returns the icon. |
java.awt.Dimension |
getMinimumSize()
Returns the minimum size for this button. |
protected java.awt.Dimension |
getPreferredIconSize(java.awt.Rectangle bounds)
Returns the preferred icon size for the specified bounds. |
protected java.awt.Dimension |
getPreferredLabelSize(java.awt.FontMetrics fm)
Returns the preferred label size. |
java.awt.Dimension |
getPreferredSize()
Returns the preferred size of this button. |
boolean |
imageUpdate(java.awt.Image image,
int flags,
int x,
int y,
int w,
int h)
The button's icon has arrived... |
boolean |
isBold()
Indicates whether the button is to be drawn in a bold font. |
boolean |
isCancel()
Indicates whether this button is the cancel button in the gui. |
boolean |
isDefault()
Indicates whether this button is the default button in the gui. |
boolean |
isSticky()
Indicates the stickiness of the button. |
void |
paint(java.awt.Graphics g)
Paints this button. |
protected java.lang.String |
paramString()
Returns the parameter string for this button. |
protected void |
processKeyEvent(java.awt.event.KeyEvent event)
Processes key events on this button by dispatching them to any registered KeyListeners. |
protected void |
processMouseEvent(java.awt.event.MouseEvent event)
Processes mouse events on this button by dispatching them to any registered MouseListeners. |
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent event)
Processes mouse motion events on this button by dispatching them to any registered MouseMotionListeners. |
void |
setAlign(int align)
Sets the button alignment. |
void |
setBold(boolean bold)
Sets the boldness of the button. |
void |
setCancel(boolean flag)
Sets this button to be the cancel button in the gui or not. |
void |
setDefault(boolean flag)
Sets this button to be the default button in the gui or not. |
void |
setEnabled(boolean flag)
Sets whether or not this button is enabled. |
void |
setIcon(java.awt.Image icon)
Sets the icon. |
void |
setIcon(java.lang.String file)
Sets the icon from a file. |
void |
setIcon(java.net.URL url)
Sets the icon from a URL. |
void |
setSticky(boolean sticky)
Sets the stickiness of the button. |
Methods inherited from class dog.gui.DCheckbox |
addActionListener, getActionCommand, getGroup, getLabel, getText, getValue, isFocusTraversable, processActionEvent, processEvent, processFocusEvent, removeActionListener, setActionCommand, setGroup, setLabel, setText, setValue, update |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int LEFT
public static final int RIGHT
protected boolean sticky
protected boolean bold
protected java.awt.Image icon
Constructor Detail |
public DButton()
public DButton(java.lang.String label)
public DButton(java.lang.String label, int align)
public DButton(java.awt.Image icon)
public DButton(java.awt.Image icon, int align)
public DButton(java.net.URL icon)
public DButton(java.net.URL icon, int align)
public DButton(java.lang.String label, java.awt.Image icon)
public DButton(java.lang.String label, java.net.URL icon)
public DButton(java.lang.String label, java.awt.Image icon, int align)
public DButton(java.lang.String label, java.net.URL icon, int align)
public DButton(java.lang.String label, DCheckboxGroup group)
public DButton(java.lang.String label, boolean value, DCheckboxGroup group)
public DButton(java.lang.String label, int align, boolean value, DCheckboxGroup group)
public DButton(java.awt.Image icon, boolean value, DCheckboxGroup group)
public DButton(java.net.URL icon, boolean value, DCheckboxGroup group)
public DButton(java.awt.Image icon, int align, boolean value, DCheckboxGroup group)
public DButton(java.net.URL icon, int align, boolean value, DCheckboxGroup group)
public DButton(java.lang.String label, java.awt.Image icon, int align, boolean value, DCheckboxGroup group)
public DButton(java.lang.String label, java.net.URL icon, int align, boolean value, DCheckboxGroup group)
Method Detail |
public boolean isSticky()
setSticky(boolean)
public void setSticky(boolean sticky)
isSticky()
public java.awt.Image getIcon()
public void setIcon(java.awt.Image icon)
icon
- the icon image.public void setIcon(java.lang.String file)
file
- the image file.public void setIcon(java.net.URL url)
url
- the image URL.public int getAlign()
getAlign
in class DCheckbox
setAlign(int)
public void setAlign(int align)
setAlign
in class DCheckbox
align
- LEFT, RIGHT, or CENTER.getAlign()
public boolean isBold()
setBold(boolean)
public void setBold(boolean bold)
isBold()
public boolean isDefault()
setDefault(boolean)
public void setDefault(boolean flag)
isDefault()
public boolean isCancel()
setCancel(boolean)
public void setCancel(boolean flag)
isCancel()
public void setEnabled(boolean flag)
setEnabled
in class DComponent
public boolean imageUpdate(java.awt.Image image, int flags, int x, int y, int w, int h)
imageUpdate
in class java.awt.Component
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class DCheckbox
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class DCheckbox
protected java.awt.Dimension getPreferredIconSize(java.awt.Rectangle bounds)
protected java.awt.Dimension getPreferredLabelSize(java.awt.FontMetrics fm)
public void paint(java.awt.Graphics g)
paint
in class DCheckbox
dog.gui.DCheckbox
ds
- the control dark shadow colour to useh
- the control highlight colour to usec
- the control colour to usepc
- the primary control colour to usepcds
- the primary control dark shadow colour to usef
- the colour to draw the dot inprotected void processKeyEvent(java.awt.event.KeyEvent event)
processKeyEvent
in class DCheckbox
event
- the key eventprotected void processMouseEvent(java.awt.event.MouseEvent event)
processMouseEvent
in class DCheckbox
event
- the mouse eventprotected void processMouseMotionEvent(java.awt.event.MouseEvent event)
processMouseMotionEvent
in class DCheckbox
event
- the mouse motion eventprotected java.lang.String paramString()
paramString
in class DCheckbox
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |