• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sub menus...

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i know how to create a sub menu bar... cause.. i really do not know how to implement it. below is the code ...
//menuBar
menuBar = new MenuBar();
m1 = new Menu("File");
m1.add("View");
m1.add("Create");
m1.add("Delete");
m1.add("Update");
m1.addSeparator();
m1.add("Exit");
m1.addActionListener(this);
m2 = new Menu("Help");
m2.add("About");
m2.add("Help Topics");
menuBar.add(m1);
menuBar.add(m2);
setMenuBar(menuBar);
i would like the view to have another 5 submenu... like customer, product, order, inventory and invoice.
like view--> customer
--> inventory
--> order
--> product
--> invoice
the tutorial from sun didn't help me solev the problem.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Menu is a subclass of MenuItem so u can add menuitems as well as menus to a menu..
what u need to do is create a view menu ,add "customer", "inventory", etc. to the view menu and then add this view menu to the file menu..
I have pasted the sample code below..
Hope this helps u
import java.awt.*;
import javax.swing.*;
public class MenuDemo extends JFrame
{
MenuBar menuBar;
Menu fileMenu,helpMenu,viewMenu;
public MenuDemo()
{
menuBar = new MenuBar();
fileMenu = new Menu("File");
viewMenu = new Menu("View");
viewMenu.add("customer");
viewMenu.add("inventory");
viewMenu.add("order");
viewMenu.add("product");
viewMenu.add("invoice");
fileMenu.add(viewMenu);
fileMenu.add("Create");
fileMenu.add("Delete");
fileMenu.add("Update");
fileMenu.addSeparator();
fileMenu.add("Exit");
helpMenu = new Menu("Help");
helpMenu.add("About");
helpMenu.add("Help Topics");
menuBar.add(fileMenu);
menuBar.add(helpMenu);
setMenuBar(menuBar);

}
public static void main(String[] args)
{
MenuDemo menuDemo = new MenuDemo();
menuDemo.setSize(300,200);
menuDemo.setVisible(true);
}
}
 
sae0203
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic