Adding Menus to and Removing Menus From Menu Bars : JMenuBar Swing Java Tutorial
Home Java Tutorial
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. Language Data Type Operators Statement Control Class Definition Development Reflection Regular Expressions Collections Thread File Generics I18N Swing Swing Event 2D Graphics SWT SWT 2D Graphics Network Database Hibernate JPA JSP JSTL Servlet Web Services SOA EJB3 Spring PDF Email J2ME J2EE Application XML
Java Tutorial Swing JMenuBar
Search
[Link] Menus to and Removing Menus From Menu Bars
Previous/Next
If you do add or remove menus, you must then revalidate() the menu bar to display the changes.
import [Link]; import [Link]; import [Link]; import [Link]; public class AddingRemovingJMenu { public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); [Link](JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar();
Are you a developer? Try out the HTML to PDF API
open in browser PRO version
[Link]
33. 34. 35. 36. 37. 38. 39.
XML Design Pattern Log Security Apache Common Ant JUnit
// File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); [Link](KeyEvent.VK_F); [Link](fileMenu); JMenu editMenu = new JMenu("Edit"); [Link](editMenu); [Link](0); [Link](); [Link](menuBar); [Link](350, 250); [Link](true); } }
[Link] 14.22.1. 14.22.2. 14.22.3.
open in browser PRO version
Creating JMenuBar Components Adding Menus to and Removing Menus From Menu Bars Menu Accelerator
[Link]
Are you a developer? Try out the HTML to PDF API
14.22.4. 14.22.5. 14.22.6. 14.22.7.
Vertical menu bar Shows how to right-align a menu in the menu bar, using a glue component Customize menu layout by changing the menu bar to use a top-tobottom box layout, and the popup menu to use a left-to-right box layout Customizing JMenuBar Look and Feel [Link] | Contact Us | Privacy Policy Copyright 2009 - 12 Demo Source and Support. All rights reserved. All other trademarks are property of their respective owners.
open in browser PRO version
Are you a developer? Try out the HTML to PDF API
[Link]