com.jmex.bui
Class BMenu

java.lang.Object
  extended by com.jmex.bui.BComponent
      extended by com.jmex.bui.BTextComponent
          extended by com.jmex.bui.BLabel
              extended by com.jmex.bui.BMenu

public class BMenu
extends BLabel

Displays a menu of items when clicked, one of which can be selected.
Example:
BWindow window = new BDecoratedWindow(style, null);
BMenuBar bar = window.getMenuBar();
BMenu fileMenu = new BMenu("File", window);
BMenuItem newItem = new BMenuItem("New Item", "NEW");
newItem.addListener(this);
fileMenu.addMenuItem(newItem);
BMenuItem exitItem = new BMenuItem("Exit", "EXIT");
exitItem.addListener(this);
fileMenu.addMenuItem(exitItem);
bar.add(fileMenu);


Styles:
menu {
border: 1 solid #999999;
background: solid #66666688;
}

menu:hover {
border: 1 solid #336699;
}

menubar {
background: solid #66666688;
}

menuitem {
border: 1 solid #999999;
background: solid #66666688;
}

menuitem:hover {
border: 1 solid #336699;
}

Version:
0.1
Author:
Devin Gillman

Nested Class Summary
protected  class BMenu.MenuItem
           
protected  class BMenu.MenuPopupMenu
           
 
Nested classes/interfaces inherited from class com.jmex.bui.BLabel
BLabel.Fit
 
Field Summary
protected  java.lang.String _action
           
protected  BMenu.MenuPopupMenu _menu
           
 
Fields inherited from class com.jmex.bui.BLabel
_label
 
Fields inherited from class com.jmex.bui.BTextComponent
_effcols, _effsizes, _haligns, _teffects, _textfacts, _valigns
 
Fields inherited from class com.jmex.bui.BComponent
_alpha, _backgrounds, _bbuf, _borders, _colors, _cursor, _enabled, _height, _hover, _insets, _listeners, _parent, _preferredSize, _properties, _styleClass, _tipmouse, _tipStyle, _tiptext, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
BMenu(java.lang.String text, ActionListener listener, java.lang.String action, BWindow parentWindow)
          Creates a menu with the specified label and action.
BMenu(java.lang.String text, BWindow parentWindow)
          Creates a menu with the specified textual label.
BMenu(java.lang.String text, java.lang.String action, BWindow parentWindow)
          Creates a menu with the specified label and action.
 
Method Summary
 void addMenuItem(BMenuItem item)
          Adds the supplied item to this menu.
 boolean dispatchEvent(BEvent event)
          Instructs this component to process the supplied event.
protected  void fireAction(long when, int modifiers)
          Called when the button is "clicked" which may due to the mouse being pressed and released while over the button or due to keyboard manipulation while the button has focus.
 java.lang.String getAction()
          Returns the action generated when this menu is clicked.
protected  java.lang.String getDefaultStyleClass()
          Returns the default stylesheet class to be used for all instances of this component.
 void setAction(java.lang.String action)
          Configures the action to be generated when this menu is clicked.
 
Methods inherited from class com.jmex.bui.BLabel
computePreferredSize, getFit, getIcon, getIconTextGap, getText, layout, renderComponent, setFit, setIcon, setIconTextGap, setOrientation, setText, wasAdded, wasRemoved
 
Methods inherited from class com.jmex.bui.BTextComponent
checkNonDefault, configureStyle, getEffectColor, getEffectSize, getHorizontalAlignment, getLabelConfig, getTextEffect, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.jmex.bui.BComponent
acceptsFocus, addListener, addListeners, applyDefaultStates, boundsToString, changeCursor, createTooltipComponent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getCursor, getFocusTarget, getHeight, getHitComponent, getInsets, getLocation, getName, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleClass, getTooltipText, getWidth, getWindow, getX, getY, hasFocus, intersectScissorBox, invalidate, isAdded, isConsumeMouseEvents, isEnabled, isHoverEnabled, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, restoreScissorState, setAlpha, setBackground, setBounds, setConsumeMouseEvents, setCursor, setEnabled, setHoverEnabled, setLocation, setName, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleClass, setTooltipRelativeToMouse, setTooltipText, setVisible, stateDidChange, updateCursor, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_action

protected java.lang.String _action

_menu

protected BMenu.MenuPopupMenu _menu
Constructor Detail

BMenu

public BMenu(java.lang.String text,
             BWindow parentWindow)
Creates a menu with the specified textual label.


BMenu

public BMenu(java.lang.String text,
             java.lang.String action,
             BWindow parentWindow)
Creates a menu with the specified label and action. The action will be dispatched via an ActionEvent when the menu is clicked.


BMenu

public BMenu(java.lang.String text,
             ActionListener listener,
             java.lang.String action,
             BWindow parentWindow)
Creates a menu with the specified label and action. The action will be dispatched via an ActionEvent to the specified ActionListener when the menu is clicked.

Method Detail

setAction

public void setAction(java.lang.String action)
Configures the action to be generated when this menu is clicked.


getAction

public java.lang.String getAction()
Returns the action generated when this menu is clicked.


dispatchEvent

public boolean dispatchEvent(BEvent event)
Description copied from class: BComponent
Instructs this component to process the supplied event. If the event is not processed, it will be passed up to its parent component for processing. Derived classes should thus only call super.dispatchEvent for events that they did not "consume".

Overrides:
dispatchEvent in class BComponent
Returns:
true if this event was consumed, false if not.

addMenuItem

public void addMenuItem(BMenuItem item)
Adds the supplied item to this menu.


getDefaultStyleClass

protected java.lang.String getDefaultStyleClass()
Description copied from class: BComponent
Returns the default stylesheet class to be used for all instances of this component. Derived classes will likely want to override this method and set up a default class for their type of component.

Overrides:
getDefaultStyleClass in class BLabel

fireAction

protected void fireAction(long when,
                          int modifiers)
Called when the button is "clicked" which may due to the mouse being pressed and released while over the button or due to keyboard manipulation while the button has focus.



Copyright © 2011 Michael Bayne. All Rights Reserved.