All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.jmf.MultiPlayer.ImageButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----com.ibm.jmf.MultiPlayer.ImageLabel
                           |
                           +----com.ibm.jmf.MultiPlayer.ImageButton

public class ImageButton
extends ImageLabel
A button class that uses an image instead of a textual label. Clicking and releasing the mouse over the button triggers an ACTION_EVENT, so you can add behavior in the same two ways as you with a normal Button (in Java 1.0):
  1. Make an ImageButton subclass and put the behavior in the action method of that subclass.
  2. Use the main ImageButton class but then catch the events in the action method of the Container.

Normally, the ImageButton's preferredSize (used, for instance, by FlowLayout) is just big enough to hold the image. However, if you give an explicit resize or reshape call before adding the ImageButton to the Container, this size will override the defaults.

See Also:
Icon, GrayFilter

Variable Index

 o actionCommand
 o actionListener
 o defaultBorderColor
Default color of 3D border around image.
 o defaultBorderWidth
Default width of 3D border around image.
 o mouseListener
 o mouseMotionListener

Constructor Index

 o ImageButton()
Create an ImageButton with the default image.
 o ImageButton(Image)
Create an ImageButton using the image specified.
 o ImageButton(String)
Create an ImageButton using the image at URL specified by the string.
 o ImageButton(String, boolean)
Create an ImageButton with the default image.
 o ImageButton(URL)
Create an ImageButton using the image at URL specified.
 o ImageButton(URL, String)
Creates an ImageButton using the file in the directory specified.

Method Index

 o addActionListener(ActionListener)
Adds the specified action listener to receive action events from this button.
 o drawBorder(boolean)
 o getActionCommand()
Returns the command name of the action event fired by this button.
 o getDarkness()
The darkness value to use for grayed images.
 o getGrayImage()
The gray image used when button is down.
 o paint(Graphics)
Draws the image.
 o processActionEvent(ActionEvent)
Processes action events occurring on this button by dispatching them to any registered ActionListener objects.
 o processEvent(AWTEvent)
Processes events on this button.
 o processMouseEvent(MouseEvent)
Processes mouse event released
 o removeActionListener(ActionListener)
Removes the specified action listener so that it no longer receives action events from this button.
 o setActionCommand(String)
Sets the command name for the action event fired by this button.
 o setDarkness(int)
An int whose bits are combined via "and" ("&") with the alpha, red, green, and blue bits of the pixels of the image to produce the grayed-out image to use when button is depressed.
 o setGrayImage(Image)
Sets gray image created automatically from regular image via an image filter to use when button is depressed.
 o setText(String)
 o waitForImage(boolean)
waitForImage needs to check if this is a text button, else call super.

Variables

 o defaultBorderWidth
 protected static final int defaultBorderWidth
Default width of 3D border around image. Currently 4.

See Also:
setBorder, getBorder
 o defaultBorderColor
 protected static final Color defaultBorderColor
Default color of 3D border around image. Currently a gray with R/G/B of 160/160/160. Light grays look best.

See Also:
setBorderColor, getBorderColor
 o actionCommand
 String actionCommand
 o actionListener
 transient ActionListener actionListener
 o mouseListener
 transient MouseListener mouseListener
 o mouseMotionListener
 transient MouseMotionListener mouseMotionListener

Constructors

 o ImageButton
 public ImageButton()
Create an ImageButton with the default image.

See Also:
getDefaultImageString
 o ImageButton
 public ImageButton(String text,
                    boolean txt)
Create an ImageButton with the default image.

See Also:
getDefaultImageString
 o ImageButton
 public ImageButton(String imageURLString)
Create an ImageButton using the image at URL specified by the string.

Parameters:
imageURLString - A String specifying the URL of the image.
 o ImageButton
 public ImageButton(URL imageURL)
Create an ImageButton using the image at URL specified.

Parameters:
imageURL - The URL of the image.
 o ImageButton
 public ImageButton(URL imageDirectory,
                    String imageFile)
Creates an ImageButton using the file in the directory specified.

Parameters:
imageDirectory - The URL of a directory
imageFile - File in the above directory
 o ImageButton
 public ImageButton(Image image)
Create an ImageButton using the image specified. You would only want to use this if you already have an image (e.g. created via createImage).

Parameters:
image - The image.

Methods

 o waitForImage
 public void waitForImage(boolean doLayout)
waitForImage needs to check if this is a text button, else call super.

Overrides:
waitForImage in class ImageLabel
 o paint
 public void paint(Graphics g)
Draws the image. If you override this in a subclass, be sure to call super.paint.

Overrides:
paint in class ImageLabel
 o setActionCommand
 public void setActionCommand(String command)
Sets the command name for the action event fired by this button. By default this action command is set to match the label of the button.

Parameters:
command - A string used to set the button's action command.
See Also:
ActionEvent
 o getActionCommand
 public String getActionCommand()
Returns the command name of the action event fired by this button.

 o addActionListener
 public synchronized void addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this button. Action events occur when a user presses or releases the mouse over this button.

Parameters:
l - the action listener.
See Also:
ActionListener, removeActionListener
 o removeActionListener
 public synchronized void removeActionListener(ActionListener l)
Removes the specified action listener so that it no longer receives action events from this button. Action events occur when a user presses or releases the mouse over this button.

Parameters:
l - the action listener.
See Also:
ActionListener, addActionListener
 o processEvent
 protected void processEvent(AWTEvent e)
Processes events on this button. If an event is an instance of ActionEvent, this method invokes the processActionEvent method. Otherwise, it invokes processEvent on the superclass.

Parameters:
e - the event.
Overrides:
processEvent in class Component
See Also:
ActionEvent, processActionEvent
 o processMouseEvent
 protected void processMouseEvent(MouseEvent e)
Processes mouse event released

Overrides:
processMouseEvent in class Component
 o processActionEvent
 protected void processActionEvent(ActionEvent e)
Processes action events occurring on this button by dispatching them to any registered ActionListener objects.

This method is not called unless action events are enabled for this button. Action events are enabled when one of the following occurs:

Parameters:
e - the action event.
See Also:
ActionListener, addActionListener, enableEvents
 o setText
 protected void setText(String t)
 o getDarkness
 public int getDarkness()
The darkness value to use for grayed images.

See Also:
setDarkness
 o setDarkness
 public void setDarkness(int darkness)
An int whose bits are combined via "and" ("&") with the alpha, red, green, and blue bits of the pixels of the image to produce the grayed-out image to use when button is depressed. Default is 0xffafafaf: af combines with r/g/b to darken image.

 o getGrayImage
 public Image getGrayImage()
The gray image used when button is down.

See Also:
setGrayImage
 o setGrayImage
 public void setGrayImage(Image grayImage)
Sets gray image created automatically from regular image via an image filter to use when button is depressed. You won't normally use this directly.

 o drawBorder
 public void drawBorder(boolean isUp)

All Packages  Class Hierarchy  This Package  Previous  Next  Index