This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JComboBox Array

 
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?
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • 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,
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!