Forums Register Login

Removing a jtable from a jpanel/Changing the table

+Pie Number of slices to send: Send
Hey..
I've written this code, which creates a table with a scrollpane, and loads the results of a search, when a button is pressed.

The problem is that each time i press the button a new jtable is created. How can i make it either:
a) refill the same table
b) remove the table and make another one which displays the new results.
My code:




Thanks
+Pie Number of slices to send: Send
If you want the same table use a Table Model and modify/renew the data in it which will reflect in the JTable. If you want to reuse a JTable...

somePanel.remove(myScrollWithJTable);
somePanel.add(new MyScrollWithJTable);
somePanel.repaint();

Something like that anyway.
+Pie Number of slices to send: Send
Thanks, i removed the table and created it again...
I couldnt figure out how to remove the table after the method ended since all my variables were valid in the {} they were declared.
So i did a panel[10].remove(panel[10].getComponent(0));
and it was ok
thanks!
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2603 times.
Similar Threads
JTable ........
Problem with JTable
JTable
JTable - JDBC - Vectors
Scrollable JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:15:26.