- Menu class in java
- Nested Class Summary
- Nested classes/interfaces inherited from class java.awt.MenuItem
- Nested classes/interfaces inherited from class java.awt.MenuComponent
- Constructor Summary
- Method Summary
- Methods inherited from class java.awt.MenuItem
- Methods inherited from class java.awt.MenuComponent
- Methods inherited from class java.lang.Object
- Methods inherited from interface java.awt.MenuContainer
- Constructor Detail
- Menu
- Menu
- Menu
- Method Detail
- addNotify
- removeNotify
- isTearOff
- getItemCount
- countItems
- getItem
- add
- add
- insert
- insert
- addSeparator
- insertSeparator
- remove
- remove
- removeAll
- paramString
- getAccessibleContext
- Class Menu
- Nested Class Summary
- Nested classes/interfaces declared in class java.awt.MenuItem
- Nested classes/interfaces declared in class java.awt.MenuComponent
- Constructor Summary
- Method Summary
- Methods declared in class java.awt.MenuItem
- Methods declared in class java.awt.MenuComponent
- Methods declared in class java.lang.Object
- Methods declared in interface java.awt.MenuContainer
- Constructor Details
- Menu
- Menu
- Menu
- Method Details
- addNotify
- removeNotify
- isTearOff
- getItemCount
- countItems
- getItem
- add
- add
- insert
- insert
- addSeparator
- insertSeparator
- remove
- remove
- removeAll
- paramString
- getAccessibleContext
Menu class in java
A Menu object is a pull-down menu component that is deployed from a menu bar. A menu can optionally be a tear-off menu. A tear-off menu can be opened and dragged away from its parent menu bar or menu. It remains on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent, since the look and feel of the tear-off menu is determined by its peer. On platforms that do not support tear-off menus, the tear-off property is ignored. Each item in a menu must belong to the MenuItem class. It can be an instance of MenuItem , a submenu (an instance of Menu ), or a check box (an instance of CheckboxMenuItem ).
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.MenuItem
Nested classes/interfaces inherited from class java.awt.MenuComponent
Constructor Summary
Method Summary
Methods inherited from class java.awt.MenuItem
Methods inherited from class java.awt.MenuComponent
Methods inherited from class java.lang.Object
Methods inherited from interface java.awt.MenuContainer
Constructor Detail
Menu
Menu
public Menu(String label) throws HeadlessException
Menu
public Menu(String label, boolean tearOff) throws HeadlessException
Constructs a new menu with the specified label, indicating whether the menu can be torn off. Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn’t support tear-off menus, this value is silently ignored.
Method Detail
addNotify
Creates the menu’s peer. The peer allows us to modify the appearance of the menu without changing its functionality.
removeNotify
Removes the menu’s peer. The peer allows us to modify the appearance of the menu without changing its functionality.
isTearOff
Indicates whether this menu is a tear-off menu. Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn’t support tear-off menus, this value is silently ignored.
getItemCount
countItems
getItem
add
Adds the specified menu item to this menu. If the menu item has been part of another menu, removes it from that menu.
add
insert
insert
Inserts a menu item with the specified label into this menu at the specified position. This is a convenience method for insert(menuItem, index) .
addSeparator
insertSeparator
public void insertSeparator(int index)
remove
public void remove(int index)
remove
removeAll
paramString
Returns a string representing the state of this Menu . This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null .
getAccessibleContext
Gets the AccessibleContext associated with this Menu. For menus, the AccessibleContext takes the form of an AccessibleAWTMenu. A new AccessibleAWTMenu instance is created if necessary.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Class Menu
A menu can optionally be a tear-off menu. A tear-off menu can be opened and dragged away from its parent menu bar or menu. It remains on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent, since the look and feel of the tear-off menu is determined by its peer. On platforms that do not support tear-off menus, the tear-off property is ignored.
Each item in a menu must belong to the MenuItem class. It can be an instance of MenuItem , a submenu (an instance of Menu ), or a check box (an instance of CheckboxMenuItem ).
Nested Class Summary
Nested classes/interfaces declared in class java.awt.MenuItem
Nested classes/interfaces declared in class java.awt.MenuComponent
Constructor Summary
Method Summary
Methods declared in class java.awt.MenuItem
Methods declared in class java.awt.MenuComponent
Methods declared in class java.lang.Object
Methods declared in interface java.awt.MenuContainer
Constructor Details
Menu
Menu
Menu
Constructs a new menu with the specified label, indicating whether the menu can be torn off. Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn’t support tear-off menus, this value is silently ignored.
Method Details
addNotify
Creates the menu’s peer. The peer allows us to modify the appearance of the menu without changing its functionality.
removeNotify
Removes the menu’s peer. The peer allows us to modify the appearance of the menu without changing its functionality.
isTearOff
Indicates whether this menu is a tear-off menu. Tear-off functionality may not be supported by all implementations of AWT. If a particular implementation doesn’t support tear-off menus, this value is silently ignored.
getItemCount
countItems
getItem
add
Adds the specified menu item to this menu. If the menu item has been part of another menu, removes it from that menu.
add
insert
insert
Inserts a menu item with the specified label into this menu at the specified position. This is a convenience method for insert(menuItem, index) .
addSeparator
insertSeparator
remove
remove
removeAll
paramString
Returns a string representing the state of this Menu . This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null .
getAccessibleContext
Gets the AccessibleContext associated with this Menu. For menus, the AccessibleContext takes the form of an AccessibleAWTMenu. A new AccessibleAWTMenu instance is created if necessary.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.