com.javaranch.common
Class LButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--com.javaranch.common.LButton
All Implemented Interfaces:
java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class LButton
extends java.awt.Component
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Lightweight button that uses images for the button.

Each button has its own up, down and disabled image.

- - - - - - - - - - - - - - - - -

Copyright (c) 1998-2004 Paul Wheaton

You are welcome to do whatever you want to with this source file provided that you maintain this comment fragment (between the dashed lines). Modify it, change the package name, change the class name ... personal or business use ... sell it, share it ... add a copyright for the portions you add ...

My goal in giving this away and maintaining the copyright is to hopefully direct developers back to JavaRanch.

The original source can be found at JavaRanch

- - - - - - - - - - - - - - - - -

Author:
Paul Wheaton
See Also:
Serialized Form

Field Summary
 
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
LButton(ButtonData d, ButtonAdapter a)
          Create a new LButton object from serialized data.
LButton(java.awt.Image upImage, java.awt.Image downImage, java.awt.Image dimImage, int x, int y, ButtonAdapter a)
           
LButton(java.lang.Object obj, java.lang.String rootImageName, int x, int y, ButtonAdapter a)
           
LButton(java.lang.String rootImageName, int x, int y, ButtonAdapter a)
           
 
Method Summary
 void addButtonListener(ButtonAdapter a)
           
 void addButtonListener(ButtonListener bl)
          Capture mouse press or release events.
 void addPressListener(PressListener pl)
          Capture mouse press events.
 void addReleaseListener(ReleaseListener rl)
          Capture mouse release events.
 void forceDown()
          Force the button to "down" mode.
 void forceUp()
          Force the button to "up" mode.
 java.awt.Dimension getPreferredSize()
          For internal use only.
 void mouseClicked(java.awt.event.MouseEvent e)
          For internal use only.
 void mouseDragged(java.awt.event.MouseEvent e)
          For internal use only.
 void mouseEntered(java.awt.event.MouseEvent e)
          For internal use only.
 void mouseExited(java.awt.event.MouseEvent e)
          For internal use only.
 void mouseMoved(java.awt.event.MouseEvent e)
          For internal use only.
 void mousePressed(java.awt.event.MouseEvent e)
          For internal use only.
 void mouseReleased(java.awt.event.MouseEvent e)
          For internal use only.
 void paint(java.awt.Graphics g)
          For internal use only.
 void setEnabled(boolean yes)
          Overrides the Component.setEnabled method so the proper image can be used.
 void update(java.awt.Graphics g)
           
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, 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, getAccessibleContext, 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, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, 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, 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, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, 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
 

Constructor Detail

LButton

public LButton(java.lang.String rootImageName,
               int x,
               int y,
               ButtonAdapter a)
        throws java.lang.Exception

LButton

public LButton(java.lang.Object obj,
               java.lang.String rootImageName,
               int x,
               int y,
               ButtonAdapter a)
        throws java.lang.Exception

LButton

public LButton(ButtonData d,
               ButtonAdapter a)
        throws java.lang.Exception
Create a new LButton object from serialized data.

Passing in the down or dim images is optional.


LButton

public LButton(java.awt.Image upImage,
               java.awt.Image downImage,
               java.awt.Image dimImage,
               int x,
               int y,
               ButtonAdapter a)
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
For internal use only.

Overrides:
getPreferredSize in class java.awt.Component

addButtonListener

public void addButtonListener(ButtonAdapter a)

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
For internal use only.

Overrides:
paint in class java.awt.Component

setEnabled

public void setEnabled(boolean yes)
Overrides the Component.setEnabled method so the proper image can be used.

Overrides:
setEnabled in class java.awt.Component

addPressListener

public void addPressListener(PressListener pl)
Capture mouse press events.


addReleaseListener

public void addReleaseListener(ReleaseListener rl)
Capture mouse release events.


addButtonListener

public void addButtonListener(ButtonListener bl)
Capture mouse press or release events.


forceUp

public void forceUp()
Force the button to "up" mode.


forceDown

public void forceDown()
Force the button to "down" mode.


mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
For internal use only.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener


Copyright ©2004 Paul Wheaton All Rights Reserved