aspose file tools*
The moose likes Beginning Java and the fly likes about array or vector and JCombobox? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

about array or vector and JCombobox?

Jhedzkie Skies
Ranch Hand

Joined: Oct 28, 2009
Posts: 118
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.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about array or vector and JCombobox?