org.w3c.tools.widgets
Class ImageButton

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by org.w3c.tools.widgets.ImageButton
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class ImageButton
extends java.awt.Canvas

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Image currentImg
           
protected  java.awt.Image img1
           
protected  java.awt.Image img2
           
protected  boolean switchable
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ImageButton(java.awt.Image img)
          Construct an ImageButton with no action command
ImageButton(java.awt.Image img1, java.awt.Image img2)
          Construct an ImageButton with the specified action command
ImageButton(java.awt.Image img1, java.awt.Image img2, java.lang.String command)
          Construct an ImageButton with the specified action command
ImageButton(java.awt.Image img, java.lang.String command)
          Construct an ImageButton with the specified action command
 
Method Summary
 void addActionListener(java.awt.event.ActionListener al)
          Adds an action listener to this ImageButton
protected  void fireActionEvent()
          fire a new ActionEvent and process it, if some listeners are listening
 java.lang.String getActionCommand()
          Returns the action command String
 java.awt.Dimension getMinimumSize()
          Returns the minimum size of the ImageButton
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the ImageButton
 boolean imageUpdate(java.awt.Image img, int flaginfo, int x, int y, int width, int height)
          called when more informations about the image are available.
protected  void initSize()
          Gets the size of the Image to calculate the minimum size of the Button
 void paint(java.awt.Graphics g)
          paint the ImageButton in its initial shape
protected  void paintShadow(boolean raised)
          paints the ImageButton using double buffering
 void removeActionListener(java.awt.event.ActionListener al)
          Removes an action listener to this ImageButton
 void setActionCommand(java.lang.String command)
          Sets the action command String used when an ActionEvent is fired
 void switchImage()
           
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

switchable

protected boolean switchable

img1

protected java.awt.Image img1

img2

protected java.awt.Image img2

currentImg

protected java.awt.Image currentImg
Constructor Detail

ImageButton

public ImageButton(java.awt.Image img1,
                   java.awt.Image img2,
                   java.lang.String command)
Construct an ImageButton with the specified action command

Parameters:
img1 - The image of this ImageButton
img2 - The image of this ImageButton
command - The action command String

ImageButton

public ImageButton(java.awt.Image img1,
                   java.awt.Image img2)
Construct an ImageButton with the specified action command

Parameters:
img1 - The image of this ImageButton
realesed - The image of this ImageButton

ImageButton

public ImageButton(java.awt.Image img,
                   java.lang.String command)
Construct an ImageButton with the specified action command

Parameters:
img - The image of this ImageButton
command - The action command String

ImageButton

public ImageButton(java.awt.Image img)
Construct an ImageButton with no action command

Parameters:
img - The image of this ImageButton
Method Detail

initSize

protected void initSize()
Gets the size of the Image to calculate the minimum size of the Button


switchImage

public void switchImage()

paint

public void paint(java.awt.Graphics g)
paint the ImageButton in its initial shape

Overrides:
paint in class java.awt.Canvas
Parameters:
g - A Graphics

paintShadow

protected void paintShadow(boolean raised)
paints the ImageButton using double buffering

Parameters:
raised - A boolean which shows the state of the button

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int flaginfo,
                           int x,
                           int y,
                           int width,
                           int height)
called when more informations about the image are available. When the size is available, the ImageButton notifies its container that the size may have changed.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Overrides:
imageUpdate in class java.awt.Component
See Also:
ImageObserver

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size of the ImageButton

Overrides:
getMinimumSize in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the ImageButton

Overrides:
getPreferredSize in class java.awt.Component

setActionCommand

public void setActionCommand(java.lang.String command)
Sets the action command String used when an ActionEvent is fired

Parameters:
command - The command String

getActionCommand

public java.lang.String getActionCommand()
Returns the action command String


addActionListener

public void addActionListener(java.awt.event.ActionListener al)
Adds an action listener to this ImageButton

Parameters:
al - The ActionListener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener al)
Removes an action listener to this ImageButton

Parameters:
al - The ActionListener

fireActionEvent

protected void fireActionEvent()
fire a new ActionEvent and process it, if some listeners are listening