File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Drop down menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drop down menu" Watch "Drop down menu" New topic
Author

Drop down menu

Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 151

Hi All,

Does anyone know how to create a "drop down menu". I have created a Calculator and I want to add more feature to it like. file menu, exit, etc.
I used JPanel to create the screen. Please let me know,

Thank you,
Gary

star chaser..
subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63
http://download.oracle.com/javase/tutorial/uiswing/components/menu.html


Subhash Kumar
Attitude is everything
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 151

Great Subhar! It looks like its what I need from the first glance.
Is this what they called Java Swing?

Gary
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 151

Ok. I have another problem. I tried creating a Menu File -> exit. The File text showed up but when "File" is selected, there is no drop down for exit. Here is the added code I've created..



What am i missing?

Thanks,
Gary
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4540
    
    5

Gary Ba wrote:What am i missing?

The initiative and staying power to systematically go through the tutorial linked by subhash (Subhar to you?).

That's not the way to use a JMenu.


luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38756
    
  23
Gary Ba wrote:Great Subhar! (sic) . . .
Is this what they called Java Swing?

Gary
Yes, and that is what they call the forum where we usually discuss that sort of question, and where I shall move this thread.
Bobby Smallman
Ranch Hand

Joined: Sep 09, 2010
Posts: 107
You definitely need to go through basic Swing tutorials asap. A few things to get you started:
You do not need to go through all of that razzmataz(its a complex scientific term meaning excessive code which doesn't really make sense) to make your JMenuItem.

A simple: is sufficient.

Last tip before you go off and dig into Swing tutorials, order does matter. So do not add your JMenuItem to a JMenu after the JMenu has been added to a JMenuBar.
Good Luck to you in all your Java and Swing endeavors!

Everyday in every way, we get a little better.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4540
    
    5

Bobby Smallman wrote:do not add your JMenuItem to a JMenu after the JMenu has been added to a JMenuBar.

How would that be a problem? Are you aware that menus are sometimes generated at runtime?
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 151

I got it!

I needed a JFrame in which the JMenuBar needed to be added.

Thanks for all the help.
Gary

Now I need to set up what JMenuItem should do.
Bobby Smallman
Ranch Hand

Joined: Sep 09, 2010
Posts: 107
Darryl Burke wrote:
Bobby Smallman wrote:do not add your JMenuItem to a JMenu after the JMenu has been added to a JMenuBar.

How would that be a problem? Are you aware that menus are sometimes generated at runtime?


I guess I was sleepy and didn't express myself accurately, I did not mean it as though it would not compile. I meant to say that your ordering of JMenuItems will be important when you have multiple items to place both visually and for readability.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drop down menu