charvax.swing

Class JMenu

Implemented Interfaces:
EventListener, ItemSelectable, KeyListener

public class JMenu
extends JMenuItem

Implements a menu containing JMenuItems and JSeparators.

Field Summary

Fields inherited from class charvax.swing.JMenuItem

_size

Fields inherited from class charvax.swing.AbstractButton

_actionListeners, _itemListeners

Fields inherited from class charvax.swing.JComponent

_border

Fields inherited from class charva.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT, _alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible

Constructor Summary

JMenu()
Constructs a new JMenu with no text (the text can be set later with the setText() method of the superclass).
JMenu(String text_)
Constructs a new JMenu with the specified string as its text
JMenu(String text_, int mnemonic_)
Constructs a new JMenu with the specified text and the specified mnemonic character (which must appear in the text).

Method Summary

JMenuItem
add(String text_)
Create a JMenuItem with the specified label and add it to the menu.
JMenuItem
add(JMenuItem item_)
Add a JMenuItem (or JMenu) to the end of this JMenu.
void
addSeparator()
Add a horizontal separator to the end of the menu.
void
debug(int level_)
Output a text description of the menu.
void
draw()
To be implemented by concrete subclasses.
void
fireActionPerformed(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this button.
int
getHeight()
JMenuItem
getMenuItem(int index_)
Returns the menu item at the specified index.
JPopupMenu
getPopupMenu()
Returns a reference to this JMenu's popup menu.
Dimension
getSize()
int
getWidth()
boolean
isPopupMenuVisible()
Returns true if the popup window of this menu is displayed.
boolean
isTopLevelMenu()
Returns true if this menu is the direct child of a menubar.
Dimension
minimumSize()
void
setBackground(Color color_)
Sets the background color of this JMenu and all its contained JMenuItems that do not yet have their background color set.
void
setForeground(Color color_)
Sets the foreground color of this JMenu and all its contained JMenuItems that do not yet have their foreground color set.
void
setPopupMenuVisible(boolean visible_)
Displays this menu's popup menu if the specified value is true; hides the menu if it is false.
String
toString()

Methods inherited from class charvax.swing.JMenuItem

debug, draw, getHeight, getSize, getWidth, minimumSize, requestFocus, toString

Methods inherited from class charvax.swing.AbstractButton

addActionListener, addItemListener, doClick, fireActionPerformed, fireItemStateChanged, getActionCommand, getLabel, getLabelString, getMnemonic, getText, isSelected, keyPressed, keyReleased, keyTyped, processEvent, processMouseEvent, removeItemListener, setActionCommand, setLabel, setMnemonic, setSelected, setText

Methods inherited from class charvax.swing.JComponent

draw, getBorder, getInsets, setBorder

Methods inherited from class charva.awt.Component

addFocusListener, addKeyListener, contains, contains, debug, draw, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getHeight, getLocation, getLocationOnScreen, getName, getParent, getSize, getWidth, hasFocus, hide, invalidate, isDisplayed, isEnabled, isFocusTraversable, isTotallyObscured, isValid, isVisible, minimumSize, processEvent, processFocusEvent, processKeyEvent, processMouseEvent, repaint, requestFocus, requestSync, setBackground, setBounds, setBounds, setBounds, setEnabled, setForeground, setLocation, setLocation, setName, setParent, setVisible, show, validate, validateCursesColor

Constructor Details

JMenu

public JMenu()
Constructs a new JMenu with no text (the text can be set later with the setText() method of the superclass).

JMenu

public JMenu(String text_)
Constructs a new JMenu with the specified string as its text

JMenu

public JMenu(String text_,
             int mnemonic_)
Constructs a new JMenu with the specified text and the specified mnemonic character (which must appear in the text).

Method Details

add

public JMenuItem add(String text_)
Create a JMenuItem with the specified label and add it to the menu.
Returns:
a reference to the newly created JMenuItem.

add

public JMenuItem add(JMenuItem item_)
Add a JMenuItem (or JMenu) to the end of this JMenu.
Returns:
the JMenuItem that was added.

addSeparator

public void addSeparator()
Add a horizontal separator to the end of the menu.

debug

public void debug(int level_)
Output a text description of the menu.
Overrides:
debug in interface JMenuItem

draw

public void draw()
To be implemented by concrete subclasses.
Overrides:
draw in interface JMenuItem

fireActionPerformed

public void fireActionPerformed(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this button.
Overrides:
fireActionPerformed in interface AbstractButton

getHeight

public int getHeight()
Overrides:
getHeight in interface JMenuItem

getMenuItem

public JMenuItem getMenuItem(int index_)
Returns the menu item at the specified index. If the object at the specified index is a JSeparator, it returns null.

getPopupMenu

public JPopupMenu getPopupMenu()
Returns a reference to this JMenu's popup menu.

getSize

public Dimension getSize()
Overrides:
getSize in interface JMenuItem

getWidth

public int getWidth()
Overrides:
getWidth in interface JMenuItem

isPopupMenuVisible

public boolean isPopupMenuVisible()
Returns true if the popup window of this menu is displayed.

isTopLevelMenu

public boolean isTopLevelMenu()
Returns true if this menu is the direct child of a menubar.

minimumSize

public Dimension minimumSize()
Overrides:
minimumSize in interface JMenuItem

setBackground

public void setBackground(Color color_)
Sets the background color of this JMenu and all its contained JMenuItems that do not yet have their background color set. Overrides the same method in the Component class.
Overrides:
setBackground in interface Component

setForeground

public void setForeground(Color color_)
Sets the foreground color of this JMenu and all its contained JMenuItems that do not yet have their foreground color set. Overrides the same method in the Component class.
Overrides:
setForeground in interface Component

setPopupMenuVisible

public void setPopupMenuVisible(boolean visible_)
Displays this menu's popup menu if the specified value is true; hides the menu if it is false.

toString

public String toString()
Overrides:
toString in interface JMenuItem