Class ui.Key
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ui.Key

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----ui.Key

public class Key
extends Canvas
A button on the calculator key pad. Each button has two modes: normal and shift. The mode is indicated by the color, either activeColor or deactiveColor. If the message label is set for the key, information about the key will be displayed on the label when it gains focus.

Variable Index

 o key
Key in normal state.
 o keyMsg
Information about the key in normal state.
 o name
Name of the key.
 o shiftkey
Key in shifted state.
 o shiftkeyMsg
Information about the key in shifted state.

Constructor Index

 o Key(String, String, String, String, String, Label)
Create a key with a name, normal key string, information about normal key string, shifted key string, information about shifted key string, and a message label.

Method Index

 o action(Event, Object)
Called if an action occurs in the Component.
 o disable()
Disable the key.
 o enable()
Enable the key.
 o key()
Return the current meaning of the key.
 o mouseDown(Event, int, int)
Called if the mouse is down.
 o mouseEnter(Event, int, int)
Called when the mouse enters the component.
 o mouseExit(Event, int, int)
Called when the mouse exits the component.
 o mouseUp(Event, int, int)
Called if the mouse is up.
 o paint(Graphics)
Paint the key.
 o setActiveColor(Color)
Set active color for the key.
 o setDeactiveColor(Color)
Set deactive color for the key.
 o setMessageLabel(Label)
Set message label for the key.
 o shift()
Shift the key.
 o update(Graphics)
Updates the component, called with a repaint().

Variables

 o name
  public String name
Name of the key.
 o key
  public String key
Key in normal state.
 o keyMsg
  public String keyMsg
Information about the key in normal state.
 o shiftkey
  public String shiftkey
Key in shifted state.
 o shiftkeyMsg
  public String shiftkeyMsg
Information about the key in shifted state.

Constructors

 o Key
  public Key(String nm,
             String str1,
             String str1msg,
             String str2,
             String str2msg,
             Label ml)
Create a key with a name, normal key string, information about normal key string, shifted key string, information about shifted key string, and a message label. If shifted key string is null, then the key does not have shifted mode.

Methods

 o setActiveColor
  public void setActiveColor(Color c)
Set active color for the key.
 o setDeactiveColor
  public void setDeactiveColor(Color c)
Set deactive color for the key.
 o setMessageLabel
  public void setMessageLabel(Label ml)
Set message label for the key.
 o key
  public String key()
Return the current meaning of the key.
 o shift
  public void shift()
Shift the key.
 o enable
  public void enable()
Enable the key.
Overrides:
enable in class Component
 o disable
  public void disable()
Disable the key.
Overrides:
disable in class Component
 o action
  public boolean action(Event evt,
                        Object arg)
Called if an action occurs in the Component. This is to be overwritten to provide callbacks to the key, or the action can be caught by the parent.
Overrides:
action in class Component
 o mouseEnter
  public boolean mouseEnter(Event evt,
                            int x,
                            int y)
Called when the mouse enters the component. Default behaviour will provide a highlight outlook, and will also update the message in the message label, if it is set.
Overrides:
mouseEnter in class Component
 o mouseExit
  public boolean mouseExit(Event evt,
                           int x,
                           int y)
Called when the mouse exits the component. Default behaviour will lose the highlight.
Overrides:
mouseExit in class Component
 o mouseDown
  public boolean mouseDown(Event evt,
                           int x,
                           int y)
Called if the mouse is down. Default behaviour will provide a button press outlook.
Overrides:
mouseDown in class Component
 o mouseUp
  public boolean mouseUp(Event evt,
                         int x,
                         int y)
Called if the mouse is up. Default behaviour will provide a button release outlook, and will deliver a ACTION event if the mouse is within the key.
Overrides:
mouseUp in class Component
 o update
  public synchronized void update(Graphics g)
Updates the component, called with a repaint().
Overrides:
update in class Component
 o paint
  public synchronized void paint(Graphics g)
Paint the key.
Overrides:
paint in class Canvas

All Packages  Class Hierarchy  This Package  Previous  Next  Index