/*
* To change this template, choose tools | templates
* And open the template in the editor.
*/
Package comm. swingcomm;
Import javax. Swing. jtable;
Import javax. Swing. Table. tablecolumn;
/**
* Jtable control public control class
* @ Author http://www.my400800.cn
*/
Public class jtablecomm {
/**
* Hide the specified column of the specified jtable
* @ Param table specify jtable
* @ Param column specify column
*/< BR> Public static void hiddencell (jtable table, int column) {
tablecolumn Tc = table. gettableheader (). getcolumnmodel (). getcolumn (column);
TC. setmaxwidth (0);
TC. setpreferredwidth (0);
TC. setwidth (0);
TC. setminwidth (0);
table. gettableheader (). getcolumnmodel (). getcolumn (column ). setmaxwidth (0);
table. gettableheader (). getcolumnmodel (). getcolumn (column ). setminwidth (0);
}
/**
* Display the specified column of the specified jtable
* @ Param table specifies the jtable
* @ Param column specifies the column
* @ Param width: Specifies the column display width.
*/
Public static void showcolumn (jtable table, int column, int width ){
Tablecolumn Tc = table. getcolumnmodel (). getcolumn (column );
TC. setmaxwidth (width );
TC. setpreferredwidth (width );
TC. setwidth (width );
TC. setminwidth (width );
Table. gettableheader (). getcolumnmodel (). getcolumn (Column). setmaxwidth (width );
Table. gettableheader (). getcolumnmodel (). getcolumn (Column). setminwidth (width );
}
}
Call method:
Hide the specified column of the specified jtable
Jtablecom. hiddencell (the jtable object of the column to be hidden, the column to be hidden starts from 0 );
Displays the specified columns of a specified jtable.
Jtablecom. hiddencell (the jtable object of the column to be displayed, the column to be displayed starts from 0, and the column width );