I've tried everything, including a search on the ranch but I couldn't really find a good example to get me started. Simply put, what I need to do is make a JTable dynamically grow by taking selected rows from some other table. I'd appreciate if you could tell me what goes in the addSelectedmethod in the code below. I'd also like to have a handle to the underlying TableModel for this dynamic table so that I can then print out all the rows that were added to the dynamic table. Code overview - There are 2 tables, dataTable & scheduledTable dataTable provides the data & you can respawn it with the "Respawn" button Rows with the boolean column selected in dataTable should be added to the scheuledTable when the user clicks "Add" Respawn, select & add to make the scheduledTable grow dynamically without loosing any previous rows.
the JTable is listening to model updates by default. it will update the view automatically. (sorry if I missed some point and did not answer the question!) cheers, Chantal
Joined: Jul 14, 2001
Hi Chantal, Thanx for the response.Your method worked great but then I chose to use the DefaultTableModel. Here's the changes to the code -
And the addSelected method goes like this
I subclassed the DefaultTableModel for the scheduledTable's TableModel so that I benefit from it's addRow method & I made the cell's not editable - the scheme worked fine. I had anticipated that the DefaultTableModel object with no args supplied to scheduledTable's constructor(from my first post) should be responsible for updating the table. But right now I realised that the I need to atleast give it the count for the number of columns, that's were I was stuck. Thanx a lot Ashish Hareet