File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

drop down menu

Amgad Sobieh

Joined: Jun 04, 2007
Posts: 4
hey guys , I need to make a drop down menu in my application .

so that when I click on it a list of object names would appear in the list.

thanks guys .
[ June 04, 2007: Message edited by: Amgad Sobieh ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
JComboBox ?
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

Welcome to the Java Ranch Amgad,

Is your JMenu static or do the objects of the class JMenuItem change? If they change, see MenuListener.

In any case, you have to call the JMenu method add() to add objects of the class JMenuItem.

Also, you'll always need a listener for the objects of JMenuItem before they'll do anything. See ActionListener actionPerformed().

If we don't answer your question, feel free to post a follow-up question.

[ June 04, 2007: Message edited by: Kaydell Leavitt ]
Amgad Sobieh

Joined: Jun 04, 2007
Posts: 4
I have tried to use the JComboBox , but I canot see , how can I insert it in a certain position on my panel .

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
using the correct layoutManager/s (often nested) usually gets you what you
want with location.

Absolute positioning (null layout) lets you specify location, but then you are
also responsible for sizing components and allowing for different user options
e.g. font/resolution/resizing etc etc. All this is handled by the layoutManager,
so using a null layoutManager is rarely recommended.
It is sorta covered in the JavaRanch Style Guide.
subject: drop down menu
Similar Threads
change the scrollbar of the select menu
What is the syntax for a "drop down menu"?
javascript overlap
How To Make an Array from Multiple Selection of a Drop-Down Menu (or Scrollable List)