how to add a jtable

hi all

my question is how to add a jtable with column name and 1 emty rom to a jpanel...

i have tried

Object[] cn = {"test", "testtest"};

JTable table = new JTable(null, cn);

i have tried the previous but it gave a nullpointerexception

please help

thanks in advance

[316 byte] By [bif_fa] at [2007-11-27 3:53:33]
# 1
Read the DefaultTableModel API. It has constructors that allow you to specify the column names and the number of empty rows.
camickra at 2007-7-12 8:57:36 > top of Java-index,Desktop,Core GUI APIs...
# 2
A JTable with one empty row and named JTableHeader is easy to create: JTable table = new JTable(new Object[][]{{""}}, new Object[]{"Title"});but did not forget to put the table in ja JScrollPane to see the headerhope it will help you
Oleka at 2007-7-12 8:57:36 > top of Java-index,Desktop,Core GUI APIs...
# 3
thanks a lot , that was very helpful
bif_fa at 2007-7-12 8:57:36 > top of Java-index,Desktop,Core GUI APIs...