Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic JTable rows  RSS feed

 
Adam Dear
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to write a program to track serial numbers of products that are sent out on sales orders. This really isn't for anyone, it is just something I came up with based on an experience I had at the place I worked while I was out of school for Christmas.
Anyway, I am trying to use a JTable to allow a user to enter a part number and a serial number in a row in two cells. As a row is populated, I need to add another blank row to the JTable. The problem is, I am not sure how to go about dynamically adding rows to a table. If a JTable is not the best way to go about this, please offer any suggestions.
As it is probably obvious, I am still trying to learn Java, and this program is nothing more than my trying to improve my understanding of the language. Please help, thanks
-A
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Adam.
Try using DefaultTableModel.addRow(...)
And here is the the section How to use Tables in the Java Tutorial.
 
Adam Dear
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info. I have it working now. One other question, is there a way I can give the first cell of the new row the focus so the the user can simply type another number without having to click in the cell first?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!