The prolem is to add info to the rows, as it's read from a file, and placed in an array: read lines from file, separate them by " ", and place each string in an array[i]. How can i get the info in array[i] inside the rows in the table? sorry for my bad explanation... ask if u don't understand what i mean
table = new JTable(data, columns);
04-26-2005, 01:32 PM
The porblem is, that i'm reading the info that goes into the table from a file. i dont know the lenght of this file, nor do i know the contents. so i cant use static declared row contents. I'm reading from the file, then places the strings into an array. I need to put the contents of the array int the rows..
04-26-2005, 01:40 PM
have fun, I recently was developing an application that at the time was using a JTable. The application, like yours, instantiated from a file. What I did was read in all the data and put it into a data structure, then evaluate the size of the data structure. I did however know how many columns would be needed ahead of time. So I created the table and used setValueAt() for specific cells. If this doesn't work because you are placing some manner of Object (other than Strings) into the table let me know and I can discuss this further.
In conclusion I hate JTable it doesn't work well for a lot of things and I had to abandon it in the end. Can I ask what functionality will be required of the table once you get your information into it?
04-26-2005, 02:03 PM
Are you asking how to add elements (rows) to a table with an unknown length? Or how to retrieve the value at a specific row? Anyhow, I would use a TableModel for your JTable.
No other functoinality is required, than printing out the contents of a file: a date, some strings, and some more strings. The first integers are ok, i read them from the file and store them in a variable. the strings are not ok, cuz i read them from the file, divide them in 2 with a split function and places them in an array. the integers (the date) are suposed to go in one colomn, the first string in the next collumn, then the second string in the last column. I don't know in advance, how many rows there will be, but there will be 3 collumns.
Is there anohter, better "thing" i can use than JTable? I just want it to look like a regular word table, no functionality, like clickinging in a cell is required.