• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get trouble in JComboBox

 
John Joe
Ranch Hand
Posts: 67
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three JComboBox and implemented with addActionListener.

Firstly, they need to click the item in MovieTitle, then the MovieDay item will be displayed based on the item selected in MovieTitle. (Ignore the MovieTime comboBox ) I did a small test here but the printed output looked weird.


Below are the output printed.

For first time, when I select "The Angry bird" (movie title), it display the day items correctly. When I select the day items , the output which is movieTitle display correctly.
However, when I select another movie again, example "ABC", it display two times "Angry bird" even I not yet select the day items, but the day items display in JComboBox correctly !!!
Capture.PNG
[Thumbnail for Capture.PNG]
 
Fred Kleinschmidt
Bartender
Posts: 451
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every time you click on combo1 you are adding another ActionListener to it. You should add one and only one action listener, when you create combo1. And dpon't create a combobox in the actionPerformed method of the first combobox. Create all three of the combo boxes at the same time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!