Class como.awt.ImageButton
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class como.awt.ImageButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----como.awt.ImageButton

public class ImageButton
extends Canvas
ImageButton is a button which uses images to represent the states of the button - normal, pressed. They don't have to be fully loaded! They will be loaded asynchronously here!

Constructor Index

 o ImageButton(Image, Image, int, int)
Construct an image button.
 o ImageButton(int, int, String)

Method Index

 o getState()
Get the current state of the switch! (if it's a button you will get true if it's currently pressed).
 o gotFocus(Event, Object)
 o imageUpdate(Image, int, int, int, int, int)
Tell me all about the image ;-) (inspired from Component.java)
 o keyDown(Event, int)
Move the focus to the next component Does NOT work! (cause nextFocus() doesn't do what I wanted)
 o lostFocus(Event, Object)
 o minimumSize()
tell my minimum-size
 o mouseDown(Event, int, int)
handle the MouseDownEvents.
 o mouseUp(Event, int, int)
handle the MouseUpEvent.
 o paint(Graphics)
Draws the picture on the screen (if parts are loaded, then it draws those parts).
 o preferredSize()
tell my preferred-size
 o sendEvent()
This delivers the Event to the parent.
 o setImages(Image, Image)
Here you may change the pictures used in the button.
 o setNoPush(boolean)
Here you can set, if you want the button to be pushed down, if someone clicks or not.
 o setState(boolean)
Set the current state of the switch! (If it is a button then do nothing!)
 o setSwitch(boolean)
Make it a Switch instead of a Button.

Constructors

 o ImageButton
  public ImageButton(Image normal,
                     Image pressed,
                     int w,
                     int h)
Construct an image button. We have two states: Normal and pressed. They both must be non-null. Then you must specify the width and height of the button. (May be different from the â– icture's size and the picture will be loaded asynchronously!)
 o ImageButton
  public ImageButton(int w,
                     int h,
                     String text)

Methods

 o setImages
  public void setImages(Image normal,
                        Image pressed)
Here you may change the pictures used in the button.
 o setSwitch
  public void setSwitch(boolean sw)
Make it a Switch instead of a Button. Now the user can press the switch and it's on or off then! You will get an action-message that the state changed. Get state with getState().
 o setNoPush
  public void setNoPush(boolean np)
Here you can set, if you want the button to be pushed down, if someone clicks or not. (Usefull if you just want to display a picture!)
 o setState
  public void setState(boolean onoff)
Set the current state of the switch! (If it is a button then do nothing!)
Parameters:
onoff - indicating on or off
 o getState
  public boolean getState()
Get the current state of the switch! (if it's a button you will get true if it's currently pressed).
Returns:
if the switch is on then return true; else false.
 o keyDown
  public boolean keyDown(Event evt,
                         int key)
Move the focus to the next component Does NOT work! (cause nextFocus() doesn't do what I wanted)
Overrides:
keyDown in class Component
 o sendEvent
  public void sendEvent()
This delivers the Event to the parent.
 o mouseDown
  public boolean mouseDown(Event event,
                           int x,
                           int y)
handle the MouseDownEvents.
Overrides:
mouseDown in class Component
 o mouseUp
  public boolean mouseUp(Event event,
                         int x,
                         int y)
handle the MouseUpEvent.
Overrides:
mouseUp in class Component
 o paint
  public void paint(Graphics graphics)
Draws the picture on the screen (if parts are loaded, then it draws those parts). Overrides paint-Method.
Overrides:
paint in class Canvas
 o preferredSize
  public Dimension preferredSize()
tell my preferred-size
Overrides:
preferredSize in class Component
 o minimumSize
  public Dimension minimumSize()
tell my minimum-size
Overrides:
minimumSize in class Component
 o gotFocus
  public boolean gotFocus(Event evt,
                          Object what)
Overrides:
gotFocus in class Component
 o lostFocus
  public boolean lostFocus(Event evt,
                           Object what)
Overrides:
lostFocus in class Component
 o imageUpdate
  public boolean imageUpdate(Image img,
                             int flags,
                             int x,
                             int y,
                             int w,
                             int h)
Tell me all about the image ;-) (inspired from Component.java)
Overrides:
imageUpdate in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index