Keine Ahnung wo der Fehler ist, aber so funktioniert es:
Code:
import javax.swing.*;
import javax.swing.table.*;
import java.util.Vector;
[...]
public TableTest() {
super("Table Test");
//nächsten 3 Zeilen
Vector columns=new Vector();
for (int i = 0; i < 7; i++) columns.add("a" + i);
DefaultTableModel tm = new DefaultTableModel(columns, 24);
//oder diese 4 Zeilen:
DefaultTableModel tm = new DefaultTableModel(24,7);
String[] titles=new String[7];
for(int i = 0; i < titles.length; i++) titles[i]=""+i;
tm.setColumnIdentifiers(titles);
//Ende; nur eine der beiden Versionen nötig
JTable tbl = new JTable(tm);
tbl.setRowSelectionAllowed(false);
this.getContentPane().add(new JScrollPane(tbl));
}
[...]
Der Fehler hat wohl irgendwas mit dem
DefaultTableColumnModel zu tun.
jak
____________________________________
Join the DNRC |
Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)