Article View: borland.public.jbuilder.java.swing
Article #8812Insert rows in the JTable
From: Khanh H. Ly
Date: Thu, 13 Jul 2000 00:00
Date: Thu, 13 Jul 2000 00:00
30 lines
1377 bytes
1377 bytes
The JTable is initialized with fix columns and rows. I would like to
add more rows to the table during runtime. Is there a way to do this?
Example code:
JTable DataJTable;
Object[] DataJTableCol = {"Col1", "Col2", "Col3"};
Object[][] DataJTableRow = {{"X1","X2","X3"},{"Y1","Y2","Y3"}};
private void jbInit() throws Exception{
DataJTable = new JTable(DataJTableRow, DataJTableCol);
.....
.........
}
public moduleA(){
//insert data into JTable
int cnt = 10;
for(int i=0; i<cnt; i++){
DataJTable.setValueAt("data"+i, i, 0);
DataJTable.setValueAt("data"+i, i, 1);
DataJTable.setValueAt("data"+i, i, 2);
}
}
When JTable tried to insert more its fixed size, it does not display
other rows. I guess I have to insert new rows, but how?
Please help
Thanks
Technical Details
Message-ID:
<396E04CD.155122CE@intervoice-brite.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,ec8e56347e278d0c,start X-Google-Attributes: gid111d45,public From: "Khanh H. Ly" <khanh.ly@intervoice-brite.com> Subject: Insert rows in the JTable Date: 2000/07/13 Message-ID: <396E04CD.155122CE@intervoice-brite.com> X-Deja-AN: 646000105 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 13 Jul 2000 10:55:38 -0800, 127.0.0.1 MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing