Class tea.set.ImageButton
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.ImageButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----tea.set.ImageButton

public class ImageButton
extends Canvas
ImageButton is a widget that behaves like a regular button. But instead of displaying a text label, it displays an image inside the button. An ImageButton can be simply constructed by supplying a plain image. A 3D button image will automatically generated. The default size of the button is the size of the image. If the button is resized to a size other than the image size, the image is scaled to the new button size.

An optional label can be specified for the button. If a label is specified, it will be show together with the image.


Variable Index

 o BOTTOM
BOTTOM specifies the label of the button being placed at the bottom of the button.
 o LEFT
LEFT specifies the label of the button being placed at the left of the button.
 o RIGHT
RIGHT specifies the label of the button being placed at the right of the button.
 o TOP
TOP specifies the label of the button being placed at the top of the button.

Constructor Index

 o ImageButton(Image)
Contruct an ImageButton with the supplied image.
 o ImageButton(Image, String)
Construct an ImageButton with image and a label.
 o ImageButton(Image, String, int)
Construct an ImageButton with image and a label.

Method Index

 o action(Event, Object)
Action routine caused by a mouse click.
 o disable()
Disable the button.
 o enable()
Enable the button.
 o getLabel()
Return the label of the button, null if none.
 o minimumSize()
Return the minimum size of the button.
 o mouseDown(Event, int, int)
Mouse down event causes a pressed button image to be shown.
 o mouseExit(Event, int, int)
Mouse exit event causes a button to change back to normal state.
 o mouseUp(Event, int, int)
Mouse up event generates an action event.
 o paint(Graphics)
Paint button.
 o preferredSize()
Return the preferred size of the button.
 o reshape(int, int, int, int)
Reshape the button.
 o resize(Dimension)
Change the size of the button to dimension.
 o resize(int, int)
Change the size of the button to (w, h).
 o setImage(Image)
Set or change the image displayed by this button.
 o setLabel(String)
Set the label for this button.
 o setLabel(String, int)
Set the label for this button.
 o setLabelPos(int)
Set the label position.

Variables

 o TOP
  public final static int TOP
TOP specifies the label of the button being placed at the top of the button.
 o LEFT
  public final static int LEFT
LEFT specifies the label of the button being placed at the left of the button.
 o BOTTOM
  public final static int BOTTOM
BOTTOM specifies the label of the button being placed at the bottom of the button.
 o RIGHT
  public final static int RIGHT
RIGHT specifies the label of the button being placed at the right of the button.

Constructors

 o ImageButton
  public ImageButton(Image iv)
Contruct an ImageButton with the supplied image.
Parameters:
iv - button image.
 o ImageButton
  public ImageButton(Image iv,
                     String label)
Construct an ImageButton with image and a label. The default label position is below the image.
Parameters:
iv - button image.
label - button label.
 o ImageButton
  public ImageButton(Image iv,
                     String label,
                     int pos)
Construct an ImageButton with image and a label. A position for the label can be specified.
Parameters:
iv - button image.
label - button label.
pos - label position flag.

Methods

 o setLabel
  public void setLabel(String label,
                       int pos)
Set the label for this button. If there was no label, the apperance of the button is going to change. The size of the button may also change depending of the label and image.
Parameters:
label - button label.
pos - label position flag.
 o setLabel
  public void setLabel(String label)
Set the label for this button. If there was no label, the apperance of the button is going to change. The size of the button may also change depending of the label and image.
Parameters:
label - button label.
 o getLabel
  public String getLabel()
Return the label of the button, null if none.
Returns:
button label.
 o setLabelPos
  public void setLabelPos(int pos)
Set the label position.
Parameters:
pos - label position flag.
 o enable
  public void enable()
Enable the button.
Overrides:
enable in class Component
 o disable
  public void disable()
Disable the button. When a button is disabled, no action is generated when users click inside the button.
Overrides:
disable in class Component
 o resize
  public void resize(int w,
                     int h)
Change the size of the button to (w, h).
Parameters:
w - button width.
h - button height.
Overrides:
resize in class Component
 o resize
  public void resize(Dimension s)
Change the size of the button to dimension.
Parameters:
s - button dimension.
Overrides:
resize in class Component
 o reshape
  public void reshape(int x,
                      int y,
                      int w,
                      int h)
Reshape the button.
Parameters:
x - x coordinate.
y - y coordinate.
w - button width.
h - button height.
Overrides:
reshape in class Component
 o action
  public boolean action(Event e,
                        Object w)
Action routine caused by a mouse click. Argument object is a reference to ImageButton itself.
Parameters:
e - event object.
w - event argument object.
Overrides:
action in class Component
 o minimumSize
  public Dimension minimumSize()
Return the minimum size of the button.
Returns:
minimum size.
Overrides:
minimumSize in class Component
 o preferredSize
  public Dimension preferredSize()
Return the preferred size of the button.
Returns:
preferred size.
Overrides:
preferredSize in class Component
 o setImage
  public synchronized void setImage(Image iv)
Set or change the image displayed by this button.
Parameters:
iv - button image.
 o paint
  public void paint(Graphics g)
Paint button.
Parameters:
g - Graphics context of this component.
Overrides:
paint in class Canvas
 o mouseDown
  public boolean mouseDown(Event e,
                           int x,
                           int y)
Mouse down event causes a pressed button image to be shown.
Parameters:
e - event object.
x - x coordinate of mouse click.
y - y coordinate of mouse click.
Overrides:
mouseDown in class Component
 o mouseExit
  public boolean mouseExit(Event e,
                           int x,
                           int y)
Mouse exit event causes a button to change back to normal state.
Parameters:
e - event object.
x - x coordinate of mouse click.
y - y coordinate of mouse click.
Overrides:
mouseExit in class Component
 o mouseUp
  public boolean mouseUp(Event e,
                         int x,
                         int y)
Mouse up event generates an action event.
Parameters:
e - event object.
x - x coordinate of mouse click.
y - y coordinate of mouse click.
Overrides:
mouseUp in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index