File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto row generation in JTable

 
Maki Jav
Ranch Hand
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can add new row with JTableModel
 
Maki Jav
Ranch Hand
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you be elaborate please?
Thanx
Maki Jav
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic