Witam, mam problem z dodaniem wierszy do tabeli. Pobieram stringa, nastepnie dziele go wg znaków (najpierw %, następnie wg " "). Wiersze do tabeli sie dodają, lecz nie tak jakbym chcial.
public static TableModel replyToTableModel(String reply, TableModel tm) {
String[] array = reply.split("%");
Vector columnNames = new Vector();
Vector rows = new Vector();
Vector newRow = new Vector();
int col = array.length;
int i = 0;
System.out.println("arrayLLLLL" + array.length);
int colCount = array.length;
for (int w = 0; w < 2; w++) {
columnNames.addElement(tm.getColumnName(w));
}
while (colCount > 0) {
for (int tmp = 0; tmp < 2; tmp++) {
colCount--;
String array2[] = array[tmp].split(" ");
newRow.add(Arrays.asList(array2).get(tmp));
}
rows.add(newRow);
}
System.out.println("FIRST: " + rows.firstElement());
System.out.println("LAST: " + rows.lastElement());
return new DefaultTableModel(rows, columnNames);
}
}