|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
com.tecnick.jrelaxtimer.ImageButton
public class ImageButton
Title: ImageButton Class
Description: Class to create image buttons with text and behaviour
Nested Class Summary | |
---|---|
(package private) class |
ImageButton.Mouse
Inner class for handing mouse events. |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
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.lang.String |
actionCommand
action command to be returned to the listener |
protected java.awt.event.ActionListener |
actionListener
the action listener (for events) |
private int |
bh
height of background image in pixels |
private boolean |
button_state
true if element is a closed node |
private int |
buttonID
menu item id to be returned on event as actionCommand |
private int |
bw
width of background image in pixels |
private int |
bx
horizontal position of background image |
private int |
by
vertical position of background image |
private float |
imageScale
float parameter to scale the image size |
private java.awt.Image |
img_bg
current background button image |
private java.awt.Image |
img_bg_off
button background image for normal state |
private java.awt.Image |
img_bg_on
button background image for button pressed |
private java.awt.Image |
img_bg_over
button background image for mouse over |
private java.awt.Image |
inactive_img
inactive image for disabled button |
protected boolean |
isMouseDown
Remember mouse up/down status |
protected boolean |
isMouseInside
Remember mouse ino/out status |
private static long |
serialVersionUID
serialVersionUID |
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()
Void Constructor |
|
ImageButton(java.awt.Image imgoff,
java.awt.Image imgon,
java.awt.Image imgover)
Constructor |
Method Summary | |
---|---|
void |
addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener to receive action events from this button. |
void |
addNotify()
Creates the Panel's peer. |
protected void |
fireActionEvent(int actiontype)
Fire an action event to the listeners. |
java.lang.String |
getActionCommand()
Returns the command name of the action event fired by this button. |
int |
getButtonID()
Get the buttonID (unique numeric identifier for current component) |
boolean |
getButtonStatus()
Get the current node status. |
protected void |
ImageButton_MouseEntered(java.awt.event.MouseEvent event)
Gets called when the mouse crosses into the connector area. |
protected void |
ImageButton_MouseExited(java.awt.event.MouseEvent event)
Gets called when the mouse crosses out of the connector area. |
protected void |
ImageButton_MousePressed(java.awt.event.MouseEvent event)
Gets called when the mouse button is pressed. |
protected void |
ImageButton_MouseReleased(java.awt.event.MouseEvent event)
Gets called when the mouse button is released on this connector. |
void |
paint(java.awt.Graphics g)
Draw button elements (border, image and label) at calculated positions |
void |
removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so it no longer receives action events from this button. |
protected void |
repaintButton()
Redraw the button object |
protected void |
repaintImages()
Redraw the button images |
void |
resize()
Resize the size of button and components. |
void |
setActionCommand(java.lang.String command)
Sets the command name of the action event fired by this button. |
void |
setBgImage(java.awt.Image i)
Set the current background image to be shown. |
void |
setButtonID(int id)
Set buttonID (unique numeric identifier for current component) |
void |
setButtonStatus(boolean status)
Set the current node status (open/closed) |
void |
setEnable(boolean a)
Enables or disables this component, depending on the value of the parameter b. |
void |
setImageScale(double f)
Scale the image to the given value (1.0 = 100%). |
void |
setImageScale(float pct)
Scale the image to the given value (1.0 = 100%). |
void |
setStateBgImages(java.awt.Image imgoff,
java.awt.Image imgon,
java.awt.Image imgover)
Set the background state images (one image for each button/mouse state) |
Methods inherited from class java.awt.Panel |
---|
getAccessibleContext |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
protected java.lang.String actionCommand
protected java.awt.event.ActionListener actionListener
protected boolean isMouseDown
protected boolean isMouseInside
private int buttonID
private java.awt.Image img_bg
private java.awt.Image img_bg_off
private java.awt.Image img_bg_on
private java.awt.Image img_bg_over
private java.awt.Image inactive_img
private float imageScale
private int bx
private int by
private int bw
private int bh
private boolean button_state
Constructor Detail |
---|
public ImageButton()
public ImageButton(java.awt.Image imgoff, java.awt.Image imgon, java.awt.Image imgover)
imgoff
- button image for mouse off stateimgon
- button image for mouse clicked stateimgover
- button image for mouse over stateMethod Detail |
---|
public void addNotify()
addNotify
in class java.awt.Panel
public void setButtonID(int id)
id
- button IDpublic int getButtonID()
public void setStateBgImages(java.awt.Image imgoff, java.awt.Image imgon, java.awt.Image imgover)
imgoff
- button background image when mouse is offimgon
- button background image when button is pressedimgover
- button background image when mouse is offpublic void setBgImage(java.awt.Image i)
i
- Button Background Imagepublic void setImageScale(double f)
f
- floatpublic void setImageScale(float pct)
pct
- floatpublic void setEnable(boolean a)
a
- If true, this component is enabled; otherwise this component is disabledpublic void resize()
protected void repaintButton()
protected void repaintImages()
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
g
- the graphic area when diplay button elementspublic boolean getButtonStatus()
public void setButtonStatus(boolean status)
status
- New status (true = closed; false = opened).public void setActionCommand(java.lang.String command)
command
- The name of the action event command fired by this buttonpublic java.lang.String getActionCommand()
public void addActionListener(java.awt.event.ActionListener l)
l
- the action listenerpublic void removeActionListener(java.awt.event.ActionListener l)
l
- the action listenerprotected void fireActionEvent(int actiontype)
actiontype
- ActionEvent.ACTION_PERFORMED,protected void ImageButton_MousePressed(java.awt.event.MouseEvent event)
event
- Mouse Eventprotected void ImageButton_MouseReleased(java.awt.event.MouseEvent event)
event
- Mouse Eventprotected void ImageButton_MouseEntered(java.awt.event.MouseEvent event)
event
- Mouse Eventprotected void ImageButton_MouseExited(java.awt.event.MouseEvent event)
event
- Mouse Event
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |