• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making the rows invisible in a tabel  RSS feed

 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to make the rows in Jtabel invisible
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to make a custom TableModel that kept track of which rows in the data are not to be displayed. Don't include those rows when asked for the row count. You would also have to map getValueAt() calls to the correct (viewable) rows.
Have a look at the Java Tutorial chapter on Tables and TableModels for the basics.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well since Java 1.6 you don't have to anymore. This version of the core libraries introduced javax.swing.RowSorter with subclasses javax.swing.DefaultRowSorter and javax.swing.table.TableRowSorter, and javax.swing.RowFilter.

Check Filter table by the text in a TextField and JTable Filtering for examples.

Now this also enables sorting on the table, but you can use the methods defined in DefaultRowSorter to disable sorting on certain columns.
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply..I'll try it..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!