Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

sub menus...  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thank you so much...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!