Class IButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--IButton

public class IButton
extends java.awt.Canvas
implements java.awt.event.MouseListener

An image button class that creates buttons that can have a text label or an image for its representation.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
static int CENTER
           
static int EAST
           
protected  java.awt.Image image
          The image for the IButton
static int NORTH
           
static int NORTHEAST
           
static int NORTHWEST
           
static int SOUTH
           
static int SOUTHEAST
           
static int SOUTHWEST
           
static int STRETCH
           
static int WEST
           
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
(package private) IButton()
          Creates a new IButton with a blank label, no image, an alignment of center and a border width of 1.
(package private) IButton(java.awt.Image _image)
          Creates a new IButton with a blank label, a specified image, an alignment of center and a border width of 1.
(package private) IButton(java.lang.String _label)
          Creates a new IButton with a specified label, no image, an alignment of center and a border width of 1.
(package private) IButton(java.lang.String _label, java.awt.Image _image)
          Creates a new IButton with non-default label and image, an alignment of center and a border width of 1.
(package private) IButton(java.lang.String _label, java.awt.Image _image, int _align)
          Creates a new IButton with non-default label, image, and alignment, and a border width of 1.
(package private) IButton(java.lang.String _label, java.awt.Image _image, int _align, int _border)
          Creates a new IButton with non-default label, image, alignment, and border width
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds an object that implements the ActionListener interface to this IButton's listener list
 void clear(java.awt.Graphics g)
          Clears the button's graphic before painting it
 java.lang.String getActionCommand()
          Gets the actionCommand used when an action event is triggered
 int getAlignment()
          Gets the alignment
 int getBorder()
          Gets the border width
 boolean getHighlight()
          Gets the current highlight status
 java.lang.String getLabel()
          Gets the IButton's current label
 java.awt.Dimension getMinimumSize()
          Gets the minimum dimensions of the button.
 java.awt.Dimension getPreferredSize()
          Gets the preferred dimensions of the button.
 void mouseClicked(java.awt.event.MouseEvent e)
          Removes the specified ActionListener from the IButton's listener list
 void mouseEntered(java.awt.event.MouseEvent e)
          Default handling mouseEntered events
 void mouseExited(java.awt.event.MouseEvent e)
          Default handling mouseExited events
 void mousePressed(java.awt.event.MouseEvent e)
          Default handling mousePressed events
 void mouseReleased(java.awt.event.MouseEvent e)
          Default handling mouseReleased events
 void paint(java.awt.Graphics g)
          Draws the IButton on the specified graphics object
 void repaint(int x, int y, int width, int height)
          Overrides the call to repaint a specific rectangle to repaint the entire IButton
 void setActionCommand(java.lang.String _actionCommand)
          Sets the actionCommand specified by the IButton when an action event is triggered
 void setAlignment(int _align)
          Sets the alignment to the input, which should be one of the constants defined in this class
 void setBorder(int _border)
          Sets the border width to the input
 void setHighlight(boolean _highlight)
           
 void setLabel(java.lang.String _label)
          Sets the IButton's label
 void setPersistentHighlight(boolean _highlight)
           
 java.lang.String toString()
          Returns a string representation of this IButton
 void update(java.awt.Graphics g)
          Is called whenever the button's graphic representation needs to be updated.
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, 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, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, 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, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER

WEST

public static final int WEST

EAST

public static final int EAST

NORTH

public static final int NORTH

SOUTH

public static final int SOUTH

NORTHWEST

public static final int NORTHWEST

NORTHEAST

public static final int NORTHEAST

SOUTHWEST

public static final int SOUTHWEST

SOUTHEAST

public static final int SOUTHEAST

STRETCH

public static final int STRETCH

image

protected java.awt.Image image
The image for the IButton
Constructor Detail

IButton

IButton(java.lang.String _label,
        java.awt.Image _image,
        int _align,
        int _border)
Creates a new IButton with non-default label, image, alignment, and border width
Parameters:
_label - the label and actionCommand
_image - the icon
_align - the alignment, from IButton's constants
_border - the width of the border, in pixels

IButton

IButton(java.lang.String _label,
        java.awt.Image _image,
        int _align)
Creates a new IButton with non-default label, image, and alignment, and a border width of 1.
Parameters:
_label - the label and actionCommand
_image - the icon
_align - the alignment, from IButton's constants

IButton

IButton(java.awt.Image _image)
Creates a new IButton with a blank label, a specified image, an alignment of center and a border width of 1.
Parameters:
_image - the icon

IButton

IButton(java.lang.String _label,
        java.awt.Image _image)
Creates a new IButton with non-default label and image, an alignment of center and a border width of 1.
Parameters:
_label - the label and actionCommand
_image - the icon

IButton

IButton(java.lang.String _label)
Creates a new IButton with a specified label, no image, an alignment of center and a border width of 1.
Parameters:
_label - the label and actionCommand

IButton

IButton()
Creates a new IButton with a blank label, no image, an alignment of center and a border width of 1.
Method Detail

setBorder

public void setBorder(int _border)
Sets the border width to the input
Parameters:
_border - the border width in pixels

getBorder

public int getBorder()
Gets the border width
Returns:
the border width, in pixels

setAlignment

public void setAlignment(int _align)
Sets the alignment to the input, which should be one of the constants defined in this class
Parameters:
_align - the new alignment

getAlignment

public int getAlignment()
Gets the alignment
Returns:
the current alignment, from the constants in this class

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred dimensions of the button.
Overrides:
getPreferredSize in class java.awt.Component
Returns:
a Dimension object with the preferred height and width

getMinimumSize

public java.awt.Dimension getMinimumSize()
Gets the minimum dimensions of the button.
Overrides:
getMinimumSize in class java.awt.Component
Returns:
a Dimension object with the minimum height and width

getHighlight

public boolean getHighlight()
Gets the current highlight status
Returns:
true if it's highlighted, false if it isn't.

setHighlight

public void setHighlight(boolean _highlight)

setPersistentHighlight

public void setPersistentHighlight(boolean _highlight)

repaint

public void repaint(int x,
                    int y,
                    int width,
                    int height)
Overrides the call to repaint a specific rectangle to repaint the entire IButton
Overrides:
repaint in class java.awt.Component
Parameters:
x - x coordinate
y - y coordinate
width - the width
height - the height

clear

public void clear(java.awt.Graphics g)
Clears the button's graphic before painting it
Parameters:
g - The Graphics object to draw to

update

public void update(java.awt.Graphics g)
Is called whenever the button's graphic representation needs to be updated. Just calls paint
Overrides:
update in class java.awt.Component
Parameters:
g - The graphics object to draw to

paint

public void paint(java.awt.Graphics g)
Draws the IButton on the specified graphics object
Overrides:
paint in class java.awt.Canvas
Parameters:
g - the Graphics object to draw to

setLabel

public void setLabel(java.lang.String _label)
Sets the IButton's label
Parameters:
_label - the new label

getLabel

public java.lang.String getLabel()
Gets the IButton's current label
Returns:
the current label

toString

public java.lang.String toString()
Returns a string representation of this IButton
Overrides:
toString in class java.awt.Component

setActionCommand

public void setActionCommand(java.lang.String _actionCommand)
Sets the actionCommand specified by the IButton when an action event is triggered
Parameters:
_actionCommand - the new actionCommand

getActionCommand

public java.lang.String getActionCommand()
Gets the actionCommand used when an action event is triggered
Returns:
the current actionCommand

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds an object that implements the ActionListener interface to this IButton's listener list
Parameters:
l - the ActionListener object to add

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Removes the specified ActionListener from the IButton's listener list
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
l - the ActionListener object to remove public synchronized void removeActionListenter (ActionListener l) { listeners.removeElement(l); } /** Default handling mouseClicked events
e - the triggered MouseEvents

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Default handling mouseEntered events
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - the triggered MouseEvents

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Default handling mouseExited events
Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - the triggered MouseEvents

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Default handling mousePressed events
Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - the triggered MouseEvents

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Default handling mouseReleased events
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - the triggered MouseEvents