<SOLVED>
Evening all. Have a small problem. Still trying to understand JTable. Problem is that I have 1 file named row.txt. The code below is for reading that file and put it in vector row. when i do System.out.print(row) it prints out all of it. But in my table it only showing first row in the file. ex if file contain.
row1 row2 row3
row4 row5 row6
Table only showing row1 row2 row2. if i add more cols. they appear. what have i missed?
|
Code:
|
public class RowClass extends DefaultTableModel {
File file = new File("c://java/row.txt");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
int count;
String str;
String[] arr;
void rowVoid() {
try{
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while ((str = dis.readLine()) !=null ){
arr = str.split(" ");
count++;
for (int i = 0; i < arr.length; i++){
row.addElement(arr [i]);
System.out.println(arr [i]);
}
}
for (int i = 0; i < count; i++) {
rowData.addElement(row);
}
fis.close();
bis.close();
dis.close();
}catch (IOException e) {
e.getStackTrace();
System.out.println("Error" +e.toString() );
}
}
} |