Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.awt.ImageButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--ncsa.horizon.awt.ImageButton

public class ImageButton
extends java.awt.Component
The ImageButton class creates and image button which performs mouse overs and handles its own mouse events. The button registers an action event when appropriate to any registered listeners. The class is used in the ZoomControl panel

See Also:
ZoomControl, Serialized Form

Field Summary
boolean overButton
          The overButton variable is set if the mouse enters
boolean pressed
          The pressed variable is set if the mouse clicks
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
ImageButton(java.awt.Image mouseOffImage, java.awt.Image mouseOnImage, int borderThickness)
          Constructs an image button with specified images and borders
 
Method Summary
void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this button.
java.awt.Dimension getMinimumSize()
          The minimum size of the button.
java.awt.Dimension getPreferredSize()
          The preferred size of the button.
void paint(java.awt.Graphics g)
          paints the button
void processMouseEvent(java.awt.event.MouseEvent e)
          Paints the button and sends an action event to all listeners.
void processMouseMotionEvent(java.awt.event.MouseEvent e)
          The processMouseMotionEvent function is necessary because other mouse events do not take care of drags that release outside of the button's x,y.
void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified action listener so it no longer receives action events from this button.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

pressed

protected boolean pressed
The pressed variable is set if the mouse clicks

overButton

protected boolean overButton
The overButton variable is set if the mouse enters
Constructor Detail

ImageButton

public ImageButton(java.awt.Image mouseOffImage,
                   java.awt.Image mouseOnImage,
                   int borderThickness)
Constructs an image button with specified images and borders
Parameters:
mouseOnImage - The image used when the mouse cursor is On the button
mouseOffImage - The image used when the mouse cursor is Off the button
borderThickness - is the width/height of the 3D border for the button
Method Detail

paint

public void paint(java.awt.Graphics g)
paints the button
Overrides:
paint in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
The preferred size of the button.
Overrides:
getPreferredSize in class java.awt.Component

getMinimumSize

public java.awt.Dimension getMinimumSize()
The minimum size of the button.
Overrides:
getMinimumSize in class java.awt.Component

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this button.
Parameters:
listener - the action listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener so it no longer receives action events from this button.
Parameters:
listener - the action listener

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent e)
Paints the button and sends an action event to all listeners.
  Here is the state machine for the various events associated
  with the image button...

  Event          Graphic used      Action          Variable set/unset
  --------------------------------------------------------------------------
  MOUSE_PRESSED  depends on x,y    none            pressed, overButton (a safety)
  MOUSE_RELEASED depends on x,y    depends on x, y pressed (unset)  
  MOUSE_EXITED   OFF Graphic       none            overButton (unset)  
  MOUSE_ENTERED  ON  Graphic       none            overButton
  MOUSE_DRAGGED  OFF Graphic       none            pressed, overButton (depends on x,y)
  
Overrides:
processMouseEvent in class java.awt.Component

processMouseMotionEvent

public void processMouseMotionEvent(java.awt.event.MouseEvent e)
The processMouseMotionEvent function is necessary because other mouse events do not take care of drags that release outside of the button's x,y.
Overrides:
processMouseMotionEvent in class java.awt.Component

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD