简体   繁体   中英

how to display certain rows in JTable

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?

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.

我认为方法是实现自己的TableModel (最好通过扩展AbstractTableModel)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM