Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill combobox from a text file

Status
Not open for further replies.

jcfrasco

IS-IT--Management
Apr 27, 2001
89
US
Hello,

I am sure this is extremely easy but I am having difficulty getting this to work. I need to know how to fill a JComboBox from a sequential file. There are only three rows and two values per each row in the file and it doesn't need to grow. I origianlly created a vector and filled the combobox with it, but now I would like to fill the vector that fills the combobox by reading in the values from a text file.

Thanks in advance for any assistance.

jcfrasco
 
import java.io.*;
import java.util.*;

try{
BufferedReader br= new BufferedReader(new FileReader(your file));
String line;
while((line=br.readLine()) !=null){
StringTokenzer tok = new StringTokenizer(line,"/t");
row1_cell1= tok.nextToken();
row1_cell2= tok.nextToken();
// you may choose to add any of these values to your vector
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top