I create JTable using DefaultTableModel
Can you help me how to hide one column from my JTable
how to hide column in jtable
Page 1 of 16 Replies - 1089 Views - Last Post: 24 July 2012 - 01:05 PM
Replies To: how to hide column in jtable
#2
Re: how to hide column in jtable
Posted 23 July 2012 - 02:53 PM
You could remove the column and then add it again later. If you made your own tablemodel (extending AbstractTableModel), you could adjust the column count and make sure the right values get returned by the method getValueAt
#3
Re: how to hide column in jtable
Posted 23 July 2012 - 03:40 PM
#4
Re: how to hide column in jtable
Posted 24 July 2012 - 12:43 PM
CasiOo, on 23 July 2012 - 02:53 PM, said:
You could remove the column and then add it again later. If you made your own tablemodel (extending AbstractTableModel), you could adjust the column count and make sure the right values get returned by the method getValueAt
but I didn't create my own AbstractTableModel ,I create JTable using DefaultTableModel but I tried much to hidding column and don't work...
sorry for mistakes,I didn't speak english very well
#5
Re: how to hide column in jtable
Posted 24 July 2012 - 12:48 PM
So extend AbstractTableModel, shouldn't be difficult if you already built your table
I even have a tutorial about it
http://www.dreaminco...h-a-tablemodel/
I even have a tutorial about it
http://www.dreaminco...h-a-tablemodel/
#6
Re: how to hide column in jtable
Posted 24 July 2012 - 12:51 PM
but data in my JTable are displayed from my database with query select * from ....
and DefaultTableMode is useful for that
and DefaultTableMode is useful for that
#7
Re: how to hide column in jtable
Posted 24 July 2012 - 01:05 PM
roona, on 24 July 2012 - 03:51 PM, said:
but data in my JTable are displayed from my database with query select * from ....
and DefaultTableMode is useful for that
and DefaultTableMode is useful for that
In that it will be even easier with your own model that extends AbstractTableModel
After all a DefaultTableModel is just an extension of AbstractTableModel that use Vector to store the data
/**
* This is an implementation of <code>TableModel</code> that
* uses a <code>Vector</code> of <code>Vectors</code> to store the
* cell value objects.
* <p>
* <strong>Warning:</strong> <code>DefaultTableModel</code> returns a
* column class of <code>Object</code>. When
* <code>DefaultTableModel</code> is used with a
* <code>TableRowSorter</code> this will result in extensive use of
* <code>toString</code>, which for non-<code>String</code> data types
* is expensive. If you use <code>DefaultTableModel</code> with a
* <code>TableRowSorter</code> you are strongly encouraged to override
* <code>getColumnClass</code> to return the appropriate type.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @version %I% %G%
* @author Philip Milne
*
* @see TableModel
* @see #getDataVector
*/
public class DefaultTableModel extends AbstractTableModel implements Serializable {
//
// Instance Variables
//
/**
* The <code>Vector</code> of <code>Vectors</code> of
* <code>Object</code> values.
*/
protected Vector dataVector;
/** The <code>Vector</code> of column identifiers. */
protected Vector columnIdentifiers;
so you can simply extend the DefaultTableModel
worst case, your Vector won't be used
This post has been edited by pbl: 24 July 2012 - 01:25 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|