charvax.swing
Class AbstractButton

java.lang.Object
  extended bycharva.awt.Component
      extended bycharvax.swing.JComponent
          extended bycharvax.swing.AbstractButton
All Implemented Interfaces:
EventListener, ItemSelectable, KeyListener
Direct Known 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  java.util.Vector _actionListeners
          A list of ActionListeners registered for this component.
protected  java.util.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
_alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
AbstractButton()
           
 
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.
 java.lang.String getActionCommand()
          Returns the action command for this button.
 java.lang.String getLabel()
          Deprecated. Replaced by getText().
protected  java.lang.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.
 java.lang.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(java.lang.String text_)
          Sets the action command for this button.
 void setLabel(java.lang.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(java.lang.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, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getHeight, getLocation, getLocationOnScreen, getName, getParent, getSize, getWidth, hasFocus, hide, invalidate, isDisplayed, isEnabled, isFocusTraversable, isTotallyObscured, isValid, isVisible, minimumSize, processFocusEvent, processKeyEvent, repaint, requestFocus, requestSync, setBackground, setBounds, setBounds, setBounds, setEnabled, setForeground, setLocation, setLocation, setName, setParent, setVisible, show, validate, validateCursesColor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_actionListeners

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


_itemListeners

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

Constructor Detail

AbstractButton

public AbstractButton()
Method Detail

setLabel

public void setLabel(java.lang.String label_)
Deprecated. Replaced by setText().


setText

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


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.

getLabel

public java.lang.String getLabel()
Deprecated. Replaced by getText().


getText

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


getMnemonic

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


setActionCommand

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


getActionCommand

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


processMouseEvent

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

Overrides:
processMouseEvent in class Component

doClick

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


setSelected

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


isSelected

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


processEvent

protected void processEvent(AWTEvent evt_)
Process events.

Overrides:
processEvent in class Component

addActionListener

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


fireActionPerformed

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


addItemListener

public void addItemListener(ItemListener il_)
Register an ItemListener object for this component.

Specified by:
addItemListener in interface ItemSelectable

removeItemListener

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

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

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

keyReleased

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

Specified by:
keyReleased in interface KeyListener

fireItemStateChanged

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


getLabelString

protected java.lang.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).