• Post Reply Bookmark Topic Watch Topic
  • New Topic

How.....change combobox1 value ....combobox2 contain value related to that....  RSS feed

 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
when i select one value in Combobox than second combobox contains the value related to the first one combobox value selection.
kindly help me... i have searched Api but i didnt find..
Thanks in advance
[ November 07, 2003: Message edited by: sandhiya Laghari ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Swing forum.
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandhya,
From your description, what I understood is there are 2 comboboxes, and when you select an item in Ist Combobox, you have to select an item in the other one - right..
If so, add an ItemListener to the Ist Combobox, and in itemStateChanged(), write your logic to select the corresponding item in the second Combobox.
 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Vijay
i want to do this:

Now when i select numbers in first combobox than combo2 contain array of numbers.
yes through actionListener but how..
thanx for help
 
Richa Goyal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sandhya
In action performed event use
if (String) combo1.getSelectedItem()=="numbers" then
combo2.add(array1())
else
combo2.add(array2())
or you can also use getSelectedIndex method of comboboxes which return an integer value starting index value from 0.
Richa.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!