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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about array or vector and JCombobox?

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
i am wondering...

how to put items from a text file into a JComboBox...

i know that JComboBoxes can display items which are in an array like JComboBox myCombo = new JComboBox(myArray);

now, i have this text file containing some sort of names like

James
Mark
Stephen
Carrey
Marcus
Vladmir
Shane

these names are inside the text file entitled StudentNames.txt



i have this idea that this will be needing I/O but i don't know how to start it.

i need to load the names from the text file to an array i think? or might be a vector. but i really dont know how to do it. getting items from a text file..

any ideas are very much appreciated.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
So there are really 2 parts to this question. Let's tackle reading a text file first. Have you tried anything at all yet? My google search turned up lots of info regarding reading a text file. Check some of those out and when you get stuck you can ask a specific question in the I/O and Streams forum.

As to the second part of your question, well, why don't we just wait for that one once you get the I/O portion down. Baby steps. I'm closing this thread because any future questions will belong in different forums.
 
    Bookmark Topic Watch Topic
  • New Topic