![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e814. Creating a Menu Item That Listens for Changes to Its Selection StatusA menu item can receive notification of selection changes by overriding itsmenuSelectionChanged() method.
See also e808 Creating a JMenuBar, JMenu, and JMenuItem Component.
JMenuItem item = new JMenuItem("Label") { // This method is called whenever the selection status of // this menu item is changed public void menuSelectionChanged(boolean isSelected) { // Always forward the event super.menuSelectionChanged(isSelected); if (isSelected) { // The menu item is selected } else { // The menu item is no longer selected } } };
e809. Separating Menu Items in a Menu e810. Creating a Popup Menu e811. Creating a Popup Menu with Nested Menus e812. Forcing a Popup Menu to Be a Heavyweight Component e813. Getting the Currently Selected Menu or Menu Item e815. Listening for Changes to the Currently Selected Menu or Menu Item © 2002 Addison-Wesley. |