• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable. (Adding more rows when needed)

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello World,
I am writting a stock Controlling program which has a billing part as well. As the bill, I have a JTable. The problem is, that I have to specify the nuber of rows initially,(JTable(rows[][],cols[]). So is there are possible way of allowing the JTable to
dynamically set the number of rows other that I initially restricting the number of rows.
I mean if the bill gets 1 item added to it , the number of rows automatically should increment by 1.
Thanks
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is there are possible way of allowing the JTable to
dynamically set the number of rows other that I initially restricting the number of rows.

JTable is normally used as an MV (Model-View) component. In the model, you specify the data and the business methods. When the data in the Model changes, the Model notifies the View, which it turn renders the data.
In your case, the Model may look something like this:

For more info, take a look at Sun's excelent How to Use Tables tutorial.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!