DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

Thread: Help With Menus

  1. #1
    Join Date
    Sep 2004
    Posts
    103

    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]

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    Make OPEN a Menu instead of a MenuItem

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Originally posted by Phaelax
    Make OPEN a Menu instead of a MenuItem
    and add the submenu items to that menu.
    eschew obfuscation

  4. #4
    Join Date
    Sep 2004
    Posts
    103

    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);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links