charvax.swing

Class AbstractButton

Implemented Interfaces:
EventListener, ItemSelectable, KeyListener
Known Direct Subclasses:
JButton, JCheckBox, JMenuItem, JRadioButton

public abstract class AbstractButton
extends JComponent
implements ItemSelectable, KeyListener

This forms the base class for components that exhibit button-like behavior.

Field Summary

protected Vector
_actionListeners
A list of ActionListeners registered for this component.
protected Vector
_itemListeners
A list of ItemListeners registered for this component.

Fields inherited from class charvax.swing.JComponent

_border

Fields inherited from class charva.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT, _alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible

Method Summary

void
addActionListener(ActionListener al_)
Register an ActionListener object for this button.
void
addItemListener(ItemListener il_)
Register an ItemListener object for this component.
void
doClick()
Programmatically performs a "click" of this button.
protected void
fireActionPerformed(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this button.
protected void
fireItemStateChanged(ItemEvent ie_)
Invoke all the ItemListener callbacks that may have been registered for this component.
String
getActionCommand()
Returns the action command for this button.
String
getLabel()
Deprecated. Replaced by getText().
protected String
getLabelString()
Returns the complete label string, including the mnemonic key surrounded by parentheses (if there is a mnemonic key and the mnemonic key does not appear within the label).
int
getMnemonic()
Returns the button's mnemonic character.
String
getText()
Returns the button's label text.
boolean
isSelected()
Returns the state of the button.
void
keyPressed(KeyEvent ke_)
Implements the KeyListener interface; this is called if a control character or a function key or cursor key was typed.
void
keyReleased(KeyEvent ke_)
Implements the KeyListener interface but is never invoked.
void
keyTyped(KeyEvent ke_)
Implements the KeyListener interface; this is called if a printable (ASCII or ISO8859-1) character was typed.
protected void
processEvent(AWTEvent evt_)
Process events.
void
processMouseEvent(MouseEvent e)
Process a MouseEvent that was generated by clicking the mouse somewhere inside this component.
void
removeItemListener(ItemListener listener_)
void
setActionCommand(String text_)
Sets the action command for this button.
void
setLabel(String label_)
Deprecated. Replaced by setText().
void
setMnemonic(int mnemonic_)
Set the button's mnemonic character.
void
setSelected(boolean state_)
Sets the state of the button.
void
setText(String label_)
Sets the button's label text.

Methods inherited from class charvax.swing.JComponent

draw, getBorder, getInsets, setBorder

Methods inherited from class charva.awt.Component

addFocusListener, addKeyListener, contains, contains, debug, draw, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getHeight, getLocation, getLocationOnScreen, getName, getParent, getSize, getWidth, hasFocus, hide, invalidate, isDisplayed, isEnabled, isFocusTraversable, isTotallyObscured, isValid, isVisible, minimumSize, processEvent, processFocusEvent, processKeyEvent, processMouseEvent, repaint, requestFocus, requestSync, setBackground, setEnabled, setForeground, setLocation, setLocation, setName, setParent, setVisible, show, validate, validateCursesColor

Field Details

_actionListeners

protected Vector _actionListeners
A list of ActionListeners registered for this component.

_itemListeners

protected Vector _itemListeners
A list of ItemListeners registered for this component.

Method Details

addActionListener

public void addActionListener(ActionListener al_)
Register an ActionListener object for this button.

addItemListener

public void addItemListener(ItemListener il_)
Register an ItemListener object for this component.
Specified by:
addItemListener in interface ItemSelectable

doClick

public void doClick()
Programmatically performs a "click" of this button.

fireActionPerformed

protected void fireActionPerformed(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this button.

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent ie_)
Invoke all the ItemListener callbacks that may have been registered for this component.

getActionCommand

public String getActionCommand()
Returns the action command for this button.

getLabel

public String getLabel()

Deprecated. Replaced by getText().


getLabelString

protected String getLabelString()
Returns the complete label string, including the mnemonic key surrounded by parentheses (if there is a mnemonic key and the mnemonic key does not appear within the label).

getMnemonic

public int getMnemonic()
Returns the button's mnemonic character.

getText

public String getText()
Returns the button's label text.

isSelected

public boolean isSelected()
Returns the state of the button.

keyPressed

public void keyPressed(KeyEvent ke_)
Implements the KeyListener interface; this is called if a control character or a function key or cursor key was typed.
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ke_)
Implements the KeyListener interface but is never invoked.
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent ke_)
Implements the KeyListener interface; this is called if a printable (ASCII or ISO8859-1) character was typed.
Specified by:
keyTyped in interface KeyListener

processEvent

protected void processEvent(AWTEvent evt_)
Process events.
Overrides:
processEvent in interface Component

processMouseEvent

public void processMouseEvent(MouseEvent e)
Process a MouseEvent that was generated by clicking the mouse somewhere inside this component.
Overrides:
processMouseEvent in interface Component

removeItemListener

public void removeItemListener(ItemListener listener_)
Specified by:
removeItemListener in interface ItemSelectable

setActionCommand

public void setActionCommand(String text_)
Sets the action command for this button.

setLabel

public void setLabel(String label_)

Deprecated. Replaced by setText().


setMnemonic

public void setMnemonic(int mnemonic_)
Set the button's mnemonic character. The mnemonic is the key which will activate this button if focus is contained somewhere within this button's ancestor window.

A mnemonic must correspond to a single key on the keyboard and should be specified using one of the VK_XXX keycodes defined in java.awt.event.KeyEvent. Mnemonics are case-insensitive, therefore a key event with the corresponding keycode would cause the button to be activated whether or not the Shift modifier was pressed.

If the character defined by the mnemonic is found within the button's label string, the first occurrence of it will be underlined to indicate the mnemonic to the user. If the corresponding character is not contained within the button's label, then it will be displayed to the right, surrounded by parentheses.

In the case of a JButton, JCheckBox or JRadioButton, this method should only be called after the button has been added to a Window, otherwise pressing the corresponding key will have no effect.

Parameters:
mnemonic_ - the keycode of the mnemonic key.

setSelected

public void setSelected(boolean state_)
Sets the state of the button. Note that this method does not post an ActionEvent.

setText

public void setText(String label_)
Sets the button's label text.