Methods Summary |
---|
public java.awt.Menu | add(java.awt.Menu m)Adds the specified menu to the menu bar.
If the menu has been part of another menu bar,
removes it from that menu bar.
synchronized (getTreeLock()) {
if (m.parent != null) {
m.parent.remove(m);
}
menus.addElement(m);
m.parent = this;
MenuBarPeer peer = (MenuBarPeer)this.peer;
if (peer != null) {
if (m.peer == null) {
m.addNotify();
}
peer.addMenu(m);
}
return m;
}
|
public void | addNotify()Creates the menu bar's peer. The peer allows us to change the
appearance of the menu bar without changing any of the menu bar's
functionality.
synchronized (getTreeLock()) {
if (peer == null)
peer = Toolkit.getDefaultToolkit().createMenuBar(this);
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
getMenu(i).addNotify();
}
}
|
java.lang.String | constructComponentName()Construct a name for this MenuComponent. Called by getName() when
the name is null.
synchronized (getClass()) {
return base + nameCounter++;
}
|
public int | countMenus()
return getMenuCountImpl();
|
public void | deleteShortcut(java.awt.MenuShortcut s)Deletes the specified menu shortcut.
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
getMenu(i).deleteShortcut(s);
}
|
int | getAccessibleChildIndex(java.awt.MenuComponent child)Defined in MenuComponent. Overridden here.
return menus.indexOf(child);
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this MenuBar.
For menu bars, the AccessibleContext takes the form of an
AccessibleAWTMenuBar.
A new AccessibleAWTMenuBar instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTMenuBar();
}
return accessibleContext;
|
public java.awt.Menu | getHelpMenu()Gets the help menu on the menu bar.
return helpMenu;
|
public java.awt.Menu | getMenu(int i)Gets the specified menu.
return getMenuImpl(i);
|
public int | getMenuCount()Gets the number of menus on the menu bar.
return countMenus();
|
final int | getMenuCountImpl()
return menus.size();
|
final java.awt.Menu | getMenuImpl(int i)
return (Menu)menus.elementAt(i);
|
public java.awt.MenuItem | getShortcutMenuItem(java.awt.MenuShortcut s)Gets the instance of MenuItem associated
with the specified MenuShortcut object,
or null if none of the menu items being managed
by this menu bar is associated with the specified menu
shortcut.
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
MenuItem mi = getMenu(i).getShortcutMenuItem(s);
if (mi != null) {
return mi;
}
}
return null; // MenuShortcut wasn't found
|
boolean | handleShortcut(java.awt.event.KeyEvent e)
// Is it a key event?
int id = e.getID();
if (id != KeyEvent.KEY_PRESSED && id != KeyEvent.KEY_RELEASED) {
return false;
}
// Is the accelerator modifier key pressed?
int accelKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
if ((e.getModifiers() & accelKey) == 0) {
return false;
}
// Pass MenuShortcut on to child menus.
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
Menu m = getMenu(i);
if (m.handleShortcut(e)) {
return true;
}
}
return false;
|
private static native void | initIDs()Initialize JNI field and method IDs
|
private void | readObject(java.io.ObjectInputStream s)Reads the ObjectInputStream .
Unrecognized keys or values will be ignored.
// HeadlessException will be thrown from MenuComponent's readObject
s.defaultReadObject();
for (int i = 0; i < menus.size(); i++) {
Menu m = (Menu)menus.elementAt(i);
m.parent = this;
}
|
public void | remove(int index)Removes the menu located at the specified
index from this menu bar.
synchronized (getTreeLock()) {
Menu m = getMenu(index);
menus.removeElementAt(index);
MenuBarPeer peer = (MenuBarPeer)this.peer;
if (peer != null) {
m.removeNotify();
m.parent = null;
peer.delMenu(index);
}
}
|
public void | remove(java.awt.MenuComponent m)Removes the specified menu component from this menu bar.
synchronized (getTreeLock()) {
int index = menus.indexOf(m);
if (index >= 0) {
remove(index);
}
}
|
public void | removeNotify()Removes the menu bar's peer. The peer allows us to change the
appearance of the menu bar without changing any of the menu bar's
functionality.
synchronized (getTreeLock()) {
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
getMenu(i).removeNotify();
}
super.removeNotify();
}
|
public void | setHelpMenu(java.awt.Menu m)Sets the specified menu to be this menu bar's help menu.
If this menu bar has an existing help menu, the old help menu is
removed from the menu bar, and replaced with the specified menu.
synchronized (getTreeLock()) {
if (helpMenu == m) {
return;
}
if (helpMenu != null) {
remove(helpMenu);
}
if (m.parent != this) {
add(m);
}
helpMenu = m;
if (m != null) {
m.isHelpMenu = true;
m.parent = this;
MenuBarPeer peer = (MenuBarPeer)this.peer;
if (peer != null) {
if (m.peer == null) {
m.addNotify();
}
peer.addHelpMenu(m);
}
}
}
|
public synchronized java.util.Enumeration | shortcuts()Gets an enumeration of all menu shortcuts this menu bar
is managing.
Vector shortcuts = new Vector();
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
Enumeration e = getMenu(i).shortcuts();
while (e.hasMoreElements()) {
shortcuts.addElement(e.nextElement());
}
}
return shortcuts.elements();
|
private void | writeObject(java.io.ObjectOutputStream s)Writes default serializable fields to stream.
s.defaultWriteObject();
|