This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox Array  RSS feed

 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I get the selected items from each objects of the combo box array and store them in a String Array?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is a bit vague.

Do you want to store all items in a combo box into a String array ?

OR

There can only be one selected item. Do you want to store a succession of these selected items in an array ?

OR

You have an array of combo box objects and you want to find the selected item in each of these combo box objects ?

Which one is it ?
 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array of combo boxes that I what to store each selected item into a string array.
JComboBox[] combo = { . . . }
String[] stored;

could I initialize the string like so
String[] stored = { combo[0].getSelected(), combo[1].getSelected() . . };

or could I try a loop:
int x = 0;
int y = 0;
do {
stored[x] = combo[y].getSelected();
x++;
y++;
}while(y < Array.getLength(combo);

I may be alittle wrong in my syntax but any corrections or easier ways to accomplish this let me know.
Thanks,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!