| Author |
Auto row generation in JTable
|
Maki Jav
Ranch Hand
Joined: May 09, 2002
Posts: 423
|
|
Hi, Is it possible to have a JTable for data entry? The idea is that this table shows only one row at start and whenever the user press tab in the last column of the table, a new row is added so that he may make new entries. This means to somehow pick up the tab key in the last column (what class/listener to use?) and genetarte a new row add it to table and update the table, being careful that previous entries are not lost...(quite a job!) The second solution may be to estimate the maximum required rows for entries and display them right from the start. But the problem in this solution is how to know that, say, the first 20 rows have data and not the remaining 30 ones? Any ideas plus code plz, Thanx in Advance Maki Jav
|
Help gets you when you need it!
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
|
you can add new row with JTableModel
|
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
|
 |
Maki Jav
Ranch Hand
Joined: May 09, 2002
Posts: 423
|
|
Would you be elaborate please? Thanx Maki Jav
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
hello, it to simple first creat defaulttablemode then add table in defaulttablemodel.. DefaultTableModel df = new DefaultTableModel(); JTable tb=new JTable(df); then u can add new row as df.addRow(new String [] {"","","","",""}); that all...
|
 |
Maki Jav
Ranch Hand
Joined: May 09, 2002
Posts: 423
|
|
That easy?!Gee thanks! Now the second part... How will I detect that the tab key was typed in the last column. I am able to get the key typed in any column of the JTable but not a specific column. Is there any solution? Thanx, Maki Jav
|
 |
 |
|
|
subject: Auto row generation in JTable
|
|
|