• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem changing the contents of a JComboBox  RSS feed

 
Samuel Oluwole
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i change the whole content of a combobox by changing the selection in another combobox.

for example, if Combobox1 contains a, b, c..with a selected, combobox2 contains "child, teen, adult"; when the user selects 'b', the contents of combobox2 shuld change to "small, big, old".

thanks in adv.
 
Fred Kleinschmidt
Bartender
Posts: 556
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems pretty simple - add an ActionListener to combobox1, and in its ActionPerformed method use combobox2's model to remove the old items and add the new ones.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or to replace the entire model of combo box 2.
 
Rob Camick
Ranch Hand
Posts: 2787
12
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!