Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Can I hide a row in my JTable ?(Swing development)
Can I hide a row in my JTable ? [message #813166] Sun, 04 March 2012 18:30 Go to next message
Eclipse UserFriend
Hi everybody.
I'm using Eclipse Indigo SR1 with JDK 1.7, on Windows 7 Pro.
I've written a desktop app, Swing based.

My app includes a JTable; it shows many records of type T, one row per record.
The table model points to Vector<T> vect, named vect, containing all data to be shown in the JTable.

The app includes a combo, named sele, showing three values: 0, 1, 2.

When sele = 0, every record of vect has to be visible in the JTable.

When sele = 1, the JTable has to show only vect records having odd row index and all records with even row index mustn't be visible. Viceversa, when sele = 2.

So, here's my question: how can I make a row not visible in the JTable ?
I can't use the table model, because it points to vect that contains "all" data.

I tried a table cell renderer, but it seems that you can set the color of a cell, but you can't set it not visible or modify its size.

I've tried another way: if r is the row index, and I want that row to be not visible, I write table.setRowHeight(r,0), but this instruction throws an exception, the height can't be set to zero.

I could solve the problem by splitting the data, dividing vect in two, but I don't like that.

Does anybody have an idea ?

thanx in advance,
William
Re: Can I hide a row in my JTable ? [message #813732 is a reply to message #813166] Mon, 05 March 2012 11:54 Go to previous messageGo to next message
Eclipse UserFriend
This forum is for questions about the Eclipse JDT tools. It isn't a forum for general Java development questions.

I can give you a hint, but you should pursue this question on a general Java forum.

You can create a filtering TableModel that wraps the existing TableModel. The filtering model would be sensitive to the filtering criteria and fire the appropriate methods (TableDataChanged) when the filter was changed. The getRowCount method would return the filtered count. The getValueAt method would map the filtered row to the actual row in the underlying TableModel.
Re: Can I hide a row in my JTable ? [message #815434 is a reply to message #813732] Wed, 07 March 2012 11:55 Go to previous messageGo to next message
Eclipse UserFriend
The JTable API has RowFilter class which can be used to filter out the data. It is used together with table's RowSorter.
Re: Can I hide a row in my JTable ? [message #815986 is a reply to message #813166] Thu, 08 March 2012 04:29 Go to previous message
Eclipse UserFriend
A simple SQL statement may be applied to the DB (through hibernate or iBatis) and required rows would be fetched instead of playing with your time consumable JTable filtering and sorting.
Previous Topic:How to do Between?
Next Topic:An Eclipse Plugin for GWT code generation
Goto Forum:
  


Current Time: Sat May 24 22:57:22 EDT 2025

Powered by FUDForum. Page generated in 0.07270 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top