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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "drop down menu " Watch "drop down menu " New topic
Author

drop down menu

Amgad Sobieh
Greenhorn

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: 689

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.

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

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 .

thanks
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.
 
Consider Paul's rocket mass heater.
 
subject: drop down menu