org.zaval.lw
Class LwButton
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
|
+--org.zaval.lw.LwActContainer
|
+--org.zaval.lw.LwButton
- All Implemented Interfaces:
- 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 can use
any other component as the button label. The component has the following
features:
-
The class performs action events when the button has been pressed. Use
the
addActionListener and removeActionListener methods to catch
the event.
-
The component uses "bt.off" view to show unpressed state and
"bt.on" view to show pressed state. The two keys are used to set appropriate
view, the default view manager reads the view as a static object by the
getView
static method of LwToolkit.class. It is possible to redefine the view using
LwAdvViewMan as follow:
...
LwButton button = new LwButton("Button");
LwAdvViewMan man = new LwAdvViewMan();
man.put("bt.off", new LwImgRender("off.gif", LwView.ORIGINAL));
man.put("bt.on", new LwImgRender("on.gif", LwView.ORIGINAL));
button.setViewMan(man);
...
-
As it has been described above the component is a composite. The sample below illustrates
how an image with a label can be used as the button title:
...
LwContainer buttonLabel = new LwPanel();
buttonLabel.setLwLayout(new LwFlowLayout());
buttonLabel.add(new LwImage("label.gif"));
buttonLabel.add(new LwLabel("Button text"));
LwButton button = new LwButton(buttonLabel);
...
| Fields inherited from class org.zaval.lw.LwCanvas |
bits, bottom, height, isValidValue, left, parent, psHeight, psWidth, right, skins, temporary, top, width, x, y |
|
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.
|
| Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, getPreferredSize, indexOf, insert, insert, invalidate, isInvalidatedByChild, laidout, remove, setBackground, setLwLayout, setOpaque, setSize, toFront, updateCashedPs, validate |
| Methods inherited from class org.zaval.lw.LwCanvas |
calcInsets, customize, cvp, getBackground, getBottom, getBounds, getHeight, getInsets, getLeft, getLocation, getLwParent, getOrigin, getPSImpl, getRight, getSize, getTop, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isValid, isVisible, paint, recalc, repaint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setViewMan, setVisible, update, vrp |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.zaval.lw.LwComponent |
getBackground, getLwComponentAt, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, paint, repaint, repaint, repaint, setBackground, setEnabled, setInsets, setLwParent, setOpaque, setViewMan, setVisible, update |
| Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
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.
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(LwVCLEvent 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(LwMouseEvent 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 event.
endDragged
public void endDragged(LwMouseEvent 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 event.
mouseMoved
public void mouseMoved(LwMouseEvent 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 event.
mouseDragged
public void mouseDragged(LwMouseEvent 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 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 overridden with the class
to set appropriate ("bt.off" or "bt.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 "un-pressed" state.
- Parameters:
b - the specified state. The true value is used to
set the "pressed" state, the false value to set the "un-pressed" state.
isPressed
public boolean isPressed()
- Gets the state of the button.
- Returns:
true if the button is "pressed", false if the button
is "un-pressed".
|