java - Wants to get Check boxes with labels -
in code, i'm adding data database. want set cell renderer label. if run code got check box.
try { list<group> listgrchild = grmgmtmodel.performlist(); (final group group : listgrchild) { table.getcolumnmodel().getcolumn(0) .setcellrenderer(new tablecellrenderer() { // method gives component whome // cell must // rendered public component gettablecellrenderercomponent( jtable table, object value, boolean isselected, boolean isfocused, int row, int col) { boolean marked = new boolean(string .valueof(value)); jcheckbox renderercomponent = new jcheckbox(); if (marked) { renderercomponent.setselected(true); } return renderercomponent; } }); tbmodel.addrow(new object[] { group.getgroupname() }); }
you comment, "rendercomponent.settext("hello")
giving last value."
verify tablemodel
has individual storage each row's check box state , label value. in example, class value
holds relevant data:
private static class value implements comparable<value> { private boolean selected; private double value; … }
the corresponding tablemodel
manages list<value>
, required renderer , editor use data each value
instance accordingly. aside, value
implements comparable
interface convenience in sorting.
Comments
Post a Comment