org.zaval.lw
Class LwButton

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
                    |
                    +--org.zaval.lw.LwActContainer
                          |
                          +--org.zaval.lw.LwButton
All Implemented Interfaces:
Drawable, java.util.EventListener, Layoutable, LayoutContainer, LwComponent, LwComposite, LwContainer, LwKeyListener, LwMouseListener, LwMouseMotionListener, Validationable

public class LwButton
extends LwActContainer
implements LwMouseListener, LwKeyListener, LwMouseMotionListener

This is button component, that is a composite component, so it is possible to use any other component as the button label. The component has following features:


Fields inherited from class org.zaval.lw.LwPanel
children
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y
 
Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwButton()
          Constructs a button component with no label.
LwButton(LwComponent t)
          Constructs a button component with the specified component as a label.
LwButton(java.lang.String lab)
          Constructs a button component with the specified label text.
 
Method Summary
 void addActionListener(LwActionListener a)
          Adds the specified action listener to receive action events from this button.
 void endDragged(LwMouseMotionEvent e)
          Invoked when the mouse ends dragged.
 void focusLost(LwFocusEvent e)
           
 boolean isPressed()
          Gets the state of the button.
 void keyPressed(LwKeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(LwKeyEvent e)
          Invoked when a key has been released.
 void keyTyped(LwKeyEvent e)
          Invoked when a key has been typed.
 void mouseClicked(LwMouseEvent e)
          Invoked when the mouse button has been clicked on a light weight component.
 void mouseDragged(LwMouseMotionEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(LwMouseEvent e)
          Invoked when the mouse enters a light weight component.
 void mouseExited(LwMouseEvent e)
          Invoked when the mouse exits a light weight component.
 void mouseMoved(LwMouseMotionEvent e)
          Invoked when the mouse pointer has been moved on a light weight component (with no buttons no down).
 void mousePressed(LwMouseEvent e)
          Invoked when the mouse button has been pressed on a light weight component.
 void mouseReleased(LwMouseEvent e)
          Invoked when the mouse button has been released on a light weight component.
protected  void perform()
          Fires the action event for list of LwActionListener.
 void removeActionListener(LwActionListener a)
          Removes the specified action listener so it no longer receives action events from this button.
protected  void setPressed(boolean b)
          Sets the specified state of the button.
 void startDragged(LwMouseMotionEvent e)
          Invoked when the mouse starts dragged.
protected  void viewManChanged()
          Invoked whenever the view manager has been set.
 
Methods inherited from class org.zaval.lw.LwActContainer
canHaveFocus, catchInput, getDefaultLayout, getFocusComponent, getRectColor, paintOnTop, remove, removeAll, setAsFocusComponent, setRectColor
 
Methods inherited from class org.zaval.lw.LwPanel
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, indexOf, insert, insert, invalidate, recalc, remove, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs
 
Methods inherited from class org.zaval.lw.LwCanvas
getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getOrigin, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, paint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, vrp
 
Methods inherited from class org.zaval.util.ValidationObject
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwContainer
add, add, getLwLayout, indexOf, insert, setLwLayout
 
Methods inherited from interface org.zaval.lw.LwComponent
getLwComponentAt, getLwParent, getViewMan, getVisiblePart, setBackground, setEnabled, setLwParent, setViewMan, setVisible
 
Methods inherited from interface org.zaval.lw.Drawable
getBackground, getOrigin, isEnabled, isOpaque, paint, repaint, repaint, setOpaque, update
 
Methods inherited from interface org.zaval.util.Validationable
invalidate, isValid, validate
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize
 
Methods inherited from interface org.zaval.lw.LayoutContainer
count, get, getLayoutOffset
 

Constructor Detail

LwButton

public LwButton()
Constructs a button component with no label.

LwButton

public LwButton(java.lang.String lab)
Constructs a button component with the specified label text. In this case the component creates LwLabel component with the text and uses it as the button label.
Parameters:
lab - the specified label text.

LwButton

public LwButton(LwComponent t)
Constructs a button component with the specified component as a label.
Parameters:
t - the specified component to be used as the button label.
Method Detail

addActionListener

public void addActionListener(LwActionListener a)
Adds the specified action listener to receive action events from this button.
Parameters:
a - the specified action listener.

removeActionListener

public void removeActionListener(LwActionListener a)
Removes the specified action listener so it no longer receives action events from this button.
Parameters:
a - the specified action listener.

perform

protected void perform()
Fires the action event for list of LwActionListener.

mouseClicked

public void mouseClicked(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been clicked on a light weight component.
Specified by:
mouseClicked in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mousePressed

public void mousePressed(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been pressed on a light weight component.
Specified by:
mousePressed in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseReleased

public void mouseReleased(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been released on a light weight component.
Specified by:
mouseReleased in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

keyPressed

public void keyPressed(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been pressed.
Specified by:
keyPressed in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

keyReleased

public void keyReleased(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been released.
Specified by:
keyReleased in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

focusLost

public void focusLost(LwFocusEvent e)

mouseEntered

public void mouseEntered(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse enters a light weight component.
Specified by:
mouseEntered in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseExited

public void mouseExited(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse exits a light weight component.
Specified by:
mouseExited in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

startDragged

public void startDragged(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when the mouse starts dragged.
Specified by:
startDragged in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

endDragged

public void endDragged(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when the mouse ends dragged.
Specified by:
endDragged in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

mouseMoved

public void mouseMoved(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when the mouse pointer has been moved on a light weight component (with no buttons no down).
Specified by:
mouseMoved in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

mouseDragged

public void mouseDragged(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Specified by:
mouseDragged in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

keyTyped

public void keyTyped(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been typed.
Specified by:
keyTyped in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

viewManChanged

protected void viewManChanged()
Invoked whenever the view manager has been set. The method is overrided with the class to set appropriate ("button.off" or "button.on") view by the view manager.
Overrides:
viewManChanged in class LwCanvas

setPressed

protected void setPressed(boolean b)
Sets the specified state of the button. The button can have "pressed" or "unpressed" state.
Parameters:
b - the specified state. The true value is used to set the "pressed" state, the false value to set the "unpressed" state.

isPressed

public boolean isPressed()
Gets the state of the button.
Returns:
true if the button is "pressed", false if the button is "unpressed".


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org