java - How to set column width of Jtable equal to a checkbox -
below picture.
i using following code it's not setting width size of checkbox
tablecolumn column = null; column = table.getcolumnmodel().getcolumn(0); column.setpreferredwidth(1);
i want remove spaces around checkbox
the tablecolumn has 3 widths, minimum, preferred , maximum.
setting width 1 makes no sense since checkbox won't paint in 1 pixel, guess minimum value being used. also, depending on auto resize property value overridden make sure column widths fill table view.
try setting minimum , preferred sizes same (reasonable) value.
a better approach not guess @ width since change different laf's. instead can use renderer determine appropriate width column. see table column adjuster basic example code can use , more complex class provides complete solution.
Comments
Post a Comment