-
Help With Menus
Okay I'm using some menus, I have a File Menu and then when I pull that down I get Open, Save, and Exit. How is it possible to make Open have a pull down menu? Like in IExplorer with New it has a submen? I can't figure it out but here is the code I have that makes the menu.
MenuBar bar = new MenuBar();
theframe.setMenuBar(bar);
Menu FileMenu = new Menu("File");
bar.add(FileMenu);
MenuItem Open = new MenuItem("Open", new MenuShortcut(KeyEvent.VK_O));
MenuItem Save = new MenuItem("Save", new MenuShortcut(KeyEvent.VK_S));
MenuItem Exit = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_E));
FileMenu.add(Open);
FileMenu.add(Save);
FileMenu.add(Exit);
Open.addActionListener(this);
Save.addActionListener(this);
Exit.addActionListener(this);[B]
-
Make OPEN a Menu instead of a MenuItem
-
Originally posted by Phaelax
Make OPEN a Menu instead of a MenuItem
and add the submenu items to that menu.
eschew obfuscation
-
thanks figured it out
MenuBar bar = new MenuBar();
theframe.setMenuBar(bar);
Menu FileMenu = new Menu("File");
Menu OpenMenu = new Menu("Open");
bar.add(FileMenu);
bar.add(OpenMenu);
MenuItem Save = new MenuItem("Save", new MenuShortcut(KeyEvent.VK_S));
MenuItem Exit = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_E));
MenuItem New = new MenuItem("New", new MenuShortcut(KeyEvent.VK_N));
FileMenu.add(OpenMenu);
OpenMenu.add(New);
FileMenu.add(Save);
FileMenu.add(Exit);
New.addActionListener(this);
OpenMenu.addActionListener(this);
Save.addActionListener(this);
Exit.addActionListener(this);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks