• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

drop down menu

 
Amgad Sobieh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JComboBox ?
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic