org.zaval.lw
Class LwMenuBar
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
|
+--org.zaval.lw.LwMenuBar
- All Implemented Interfaces:
- java.util.EventListener, Layoutable, LayoutContainer, LwChildrenListener, LwComponent, LwContainer, LwKeyListener, Switchable, Validationable
- public class LwMenuBar
- extends LwPanel
- implements LwChildrenListener, LwKeyListener, Switchable
This is menu bar component. There is not any special requirement how to use the component like it
should be done for Java AWT menu bar. You can use the component like any other light weight component
in any preferable part of your application or applet. The component basic features
are listed below:
-
The item selection borders views can be customized by the
setView method. The views
define the borders to be rendered around activated and not activated menu bar items.
-
You can use any lightweight component as the menu bar item. So you can customize the
items views. For example if you want to have menu item highlighting use the LwLink
component as the menu bar item as follow:
...
LwMenuBar bar = new LwMenuBar();
bar.add (new LwLink("Highlighting Item"));
...
-
It is possible to use any preferable layout manager to place the menu bar items. For example
to have a menu bar oriented vertically you can use the LwListLayout layout manager as follow:
...
LwMenuBar bar = new LwMenuBar();
bar.setLwLayout(new LwListLayout());
bar.add ("Item 1");
bar.add ("Item 2");
bar.add ("Item 3");
...
|
Field Summary |
static int |
OFF_BR_VIEW
The none active border element id. |
static int |
ON_BR_VIEW
The active border element id. |
| 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 |
LwMenuBar()
Constructs a menu bar component. |
|
Method Summary |
void |
add(LwComponent c,
LwMenu m)
Adds the specified menu bar item component that is bound with the given popup menu. |
void |
add(java.lang.String title,
LwMenu m)
Adds the specified menu bar item that is bound with the given popup menu. |
void |
childPerformed(LwVCLEvent e)
Invoked whenever the child event has been performed. |
protected LwLayout |
getDefaultLayout()
Gets the default layout manager that is set with the container during initialization.
|
protected LwMenu |
getMenu(LwComponent c)
Gets the popup menu component that is associated with the specified menu bar item component. |
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 |
paintOnTop(java.awt.Graphics g)
Paints additional elements (for example marker) after the container and its child components
have been rendered. |
void |
remove(int i)
Removes the component at the specified index from this container.
|
void |
removeAll()
Removes all child components from this container.
|
void |
setMenu(int index,
LwMenu m)
Binds the specified menu bar item with the given popup menu. |
void |
setView(int type,
LwView v)
Sets the specified view for the given element type. |
void |
switched(boolean b)
Invoked when the state of a switching component has been changed. |
| 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, canHaveFocus, 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, viewManChanged, 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 |
canHaveFocus, getBackground, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, paint, repaint, repaint, repaint, setEnabled, setInsets, setLwParent, setViewMan, setVisible, update |
ON_BR_VIEW
public static final int ON_BR_VIEW
- The active border element id.
OFF_BR_VIEW
public static final int OFF_BR_VIEW
- The none active border element id.
LwMenuBar
public LwMenuBar()
- Constructs a menu bar component.
setView
public void setView(int type,
LwView v)
- Sets the specified view for the given element type. It is necessary to use
one of the following constants as the element type:
- ON_BR_VIEW - to specify active border view.
- OFF_BR_VIEW - to specify none active border view.
- Parameters:
type - the specified element type.v - the specified view for the element type.
add
public void add(java.lang.String title,
LwMenu m)
- Adds the specified menu bar item that is bound with the given popup menu.
- Parameters:
title - the specified menu bar item. The title string is used to
create LwLabel component and insert it as the menu bar item.m - the specified popup menu component that is bound with the menu bar item.
add
public void add(LwComponent c,
LwMenu m)
- Adds the specified menu bar item component that is bound with the given popup menu.
- Parameters:
c - the specified menu bar item component.m - the specified popup menu component that is bound with the menu bar item.
setMenu
public void setMenu(int index,
LwMenu m)
- Binds the specified menu bar item with the given popup menu.
- Parameters:
index - the specified menu bar item index.m - the specified popup menu component.
remove
public void remove(int i)
- Description copied from class:
LwPanel
- Removes the component at the specified index from this container.
The layout manager of this container is informed by calling
componentRemoved method of the manager.
- Overrides:
remove in class LwPanel
- Following copied from class:
org.zaval.lw.LwPanel
- Parameters:
i - the index of the component to be removed.
removeAll
public void removeAll()
- Description copied from class:
LwPanel
- Removes all child components from this container.
The layout manager of this container is informed by calling
componentRemoved method of the manager for every child that has been
removed.
- Overrides:
removeAll in class LwPanel
childPerformed
public void childPerformed(LwVCLEvent e)
- Description copied from interface:
LwChildrenListener
- Invoked whenever the child event has been performed.
- Specified by:
childPerformed in interface LwChildrenListener
- Following copied from interface:
org.zaval.lw.event.LwChildrenListener
- Parameters:
e - the child event.
paintOnTop
public void paintOnTop(java.awt.Graphics g)
- Description copied from interface:
LwContainer
- Paints additional elements (for example marker) after the container and its child components
have been rendered.
- Overrides:
paintOnTop in class LwPanel
- Following copied from interface:
org.zaval.lw.LwContainer
- Parameters:
g - the graphics context.
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.
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.
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.
switched
public void switched(boolean b)
- Description copied from interface:
Switchable
- Invoked when the state of a switching component has been changed.
- Specified by:
switched in interface Switchable
- Following copied from interface:
org.zaval.lw.Switchable
- Parameters:
state - the component state. true
if the component has "on" state and false if the
component has "off" state.
getMenu
protected LwMenu getMenu(LwComponent c)
- Gets the popup menu component that is associated with the specified menu bar item component.
- Parameters:
c - the specified menu bar item component.- Returns:
- a popup menu component.
getDefaultLayout
protected LwLayout getDefaultLayout()
- Description copied from class:
LwPanel
- Gets the default layout manager that is set with the container during initialization.
This implementation of the method returns LwRastLayout as the default layout manager, the
layout manager is got as a static object by "def.lay" key.
- Overrides:
getDefaultLayout in class LwPanel
- Following copied from class:
org.zaval.lw.LwPanel
- Returns:
- a layout manager.
|