jewl
Class Button

java.lang.Object
  extended byjewl.Window
      extended byjewl.Control
          extended byjewl.TextControl
              extended byjewl.Button

public class Button
extends TextControl

A text control which generates a command code (a character) when it is pressed. Like other text controls, the program can get and set the text displayed on the button, but unlike other text controls setting the alignment has no effect. The text displayed on a button is always centered, and the button takes up the whole of the space allocated to it.


Field Summary
 
Fields inherited from class jewl.TextControl
CENTER, CENTRE, LEFT, RIGHT
 
Constructor Summary
Button(Container parent, int left, int top, int width, int height, java.lang.String text, char action)
          Construct a new button.
 
Method Summary
 void activate()
          Activate this button as if it was selected by a mouse click.
 void setDefault()
          Set this button to be the default button.
 void setKey(char key)
          Set a mnemonic key.
 
Methods inherited from class jewl.TextControl
getAlignment, getText, setAlignment, setText
 
Methods inherited from class jewl.Control
disable, enable, enable, getToolTip, isEnabled, setToolTip
 
Methods inherited from class jewl.Window
addEventListener, commandAvailable, getCommand, getFont, getHeight, getID, getLeft, getScreenHeight, getScreenWidth, getSource, getTop, getWidth, hide, init, isVisible, nextCommand, parent, root, setFont, setID, setLocation, setSize, show, show
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Button

public Button(Container parent,
              int left,
              int top,
              int width,
              int height,
              java.lang.String text,
              char action)
Construct a new button. The command code generated when the button is pressed is specified as the last parameter.

Parameters:
parent - the button's parent window.
left - the position of the left edge of the button relative to its parent. If this is negative, it is taken to be relative to the right edge of the parent window. If the parent window is resized, the button will be moved to maintain the same relative position.
top - the position of the top edge of the button relative to its parent. If this is negative, it is taken to be relative to the bottom edge of the parent window. If the parent window is resized, the button will be moved to maintain the same relative position.
width - the width of the button. If this is zero or negative, it is taken to be relative to the width of the parent window. If the parent window is resized, the button will be resized to maintain the same relative width.
height - the height of the button. If this is zero or negative, it is taken to be relative to the height of the parent window. If the parent window is resized, the button will be resized to maintain the same relative height.
text - the initial text displayed by the button.
action - the command code generated when the button is pressed.
Method Detail

activate

public void activate()
Activate this button as if it was selected by a mouse click. This generates the command code associated with the button.


setKey

public void setKey(char key)
Set a mnemonic key. The possible mnemonics are Alt-A to Alt-Z, and Alt-0 to Alt-9. Pressing the designated key will have the same effect as pressing the button using the mouse. The first occurrence of the letter or digit in the text displayed on the button will be underlined as a visual reminder of the mnemonic.

Overrides:
setKey in class TextControl
Parameters:
key - a letter or digit which will activate the button when pressed together with the Alt key. Anything other than a letter or digit will be ignored.

setDefault

public void setDefault()
Set this button to be the default button. The default button is the one that can be pressed.using the Enter or Ctrl-Enter key. Any button automatically becomes the default button when it is activated.