• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable-new rows

 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to show one empty row to the user in a Table.If he wants more rows,he should be able to add new empty rows.What is the best way of achieving this functionality(give a button like"New Row")
thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal,
Create your own TableModel and have it hooked into the actionPerformed on the Button in some manner, either by direct reference to the model or by firing a property change. Your easiest go would be to extend AbstractTableModel. You would need to keep a state variable to hold the number of rows and that would be returned in the getRowCount() method of the model.
Michael Morris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!