Reputation: 67
Hello I have a JTable
and there a 3 radio buttons at the bottom when the user clicks the buttons I want the JTable
to only show certain rows for that button. I've tried deleting the rows when the button is pressed but I get an error when i click the other button that re-adds them. Is there anyway I can just hide the rows when the button is pressed and show them when the other button is pushed?
Upvotes: 1
Views: 134
Reputation: 1133
I think the way to go is implementing your own TableModel (preferably by extending AbstractTableModel)
Upvotes: 0
Reputation: 324128
Is there anyway I can just hide the rows when the button is pressed and show them when the other button is pushed?
Use a RowFilter
for your table. So you need some data in the table that you will be able to specify a filter for. Every time you click the button you will need to change the filter for the new requirements.
Read the section from the Swing tutorial on Sorting and Filtering for more information and working examples.
Upvotes: 2