wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes sub menus... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "sub menus..." Watch "sub menus..." New topic
Author

sub menus...

sae0203
Ranch Hand

Joined: Sep 19, 2002
Posts: 34
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.


SAE <br /> <br /><a href="http://www.findsingapore.net/forum" target="_blank" rel="nofollow">http://www.findsingapore.net/forum</a>
Priya Mahale
Greenhorn

Joined: Sep 30, 2002
Posts: 4
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

Joined: Sep 19, 2002
Posts: 34
Thank you so much...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sub menus...
 
Similar Threads
package problem
link from the main menu to other
help needed 4 package!!!
JMenu/Sub-menu creation
link from menubar to the selected page