• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with Drop list

 
neznam te
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just can't figure this out The code compiles but it won't work. It won't do what I want it to do.

I need to make it when you click on a pet in the drop list. the name will come up in JLabel under it

When an item is clicked show in a JLabel the name of the item that was clicked. .

The code compiles and I get the drop down list. But When I Select any of the items I am supposed to get label under it saying what I have chosen but it's not working.



Thank you
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The problem is in the action listener e.getSource(). What does this return? JComboBox.

How to get the selected item from the combo box? Also for string comparison use equals() not ==.
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to get the selected item from the combo box:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!