adm
Class CMenuButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Button
              |
              +--adm.CMenuButton

public class CMenuButton
extends java.awt.Button
implements java.awt.event.ActionListener

This class creates a stand-alone menu button. It does not need to be added to a menuBar. CMenuBotton looks like a button but works like a menu. When the button is pressed, a pull down menu will appear.

Like awt.Menu, any menuItem, separator and subclass of menuItem such as JavaMenuItem and ShellMenuItem can be added to this widget.

To distinguish from a normal awt.Button, a ">>" String is added on back of the label set by the user. If the label is not set, the default label ">>" will appear on the CMenuBotton.

Since:
adm0.3
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CMenuButton()
          Null constructor.
CMenuButton(java.lang.String label)
          Constructor with label parameter
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Popup a popup menu at position (0, height of button)
 java.awt.MenuItem add(java.awt.MenuItem mi)
          Adds the specified menu item to this menu.
 void addSeparator()
          Adds a separator line, or a hypen, to the menu at the current position.
 java.lang.String getLabel()
          Return the label string (not include " >>").
 void insert(java.awt.MenuItem mi, int index)
          Inserts a menu item into this menu at the specified position.
 void insertSeparator(int index)
          Inserts a separator at the specified position.
 void remove(int index)
          Removes the menu item at the specified index from this menuButton.
 void remove(java.awt.MenuComponent item)
          Removes the specified menu item from this menuButton.
 void setLabel(java.lang.String label)
          Set the label string.
 
Methods inherited from class java.awt.Button
addActionListener, addNotify, getActionCommand, removeActionListener, setActionCommand
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CMenuButton

public CMenuButton()
Null constructor.

CMenuButton

public CMenuButton(java.lang.String label)
Constructor with label parameter
Parameters:
label - label string
Method Detail

getLabel

public java.lang.String getLabel()
Return the label string (not include " >>").
Overrides:
getLabel in class java.awt.Button

setLabel

public void setLabel(java.lang.String label)
Set the label string. The real label will be label+" >>".
Overrides:
setLabel in class java.awt.Button
Parameters:
label - the label String

add

public java.awt.MenuItem add(java.awt.MenuItem mi)
Adds the specified menu item to this menu. If the menu item has been part of another menu, remove it from that menu.

addSeparator

public void addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.

insert

public void insert(java.awt.MenuItem mi,
                   int index)
Inserts a menu item into this menu at the specified position.

remove

public void remove(int index)
Removes the menu item at the specified index from this menuButton.

remove

public void remove(java.awt.MenuComponent item)
Removes the specified menu item from this menuButton.
Overrides:
remove in class java.awt.Component

insertSeparator

public void insertSeparator(int index)
Inserts a separator at the specified position.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Popup a popup menu at position (0, height of button)
Specified by:
actionPerformed in interface java.awt.event.ActionListener