java - Issues with JTable Row Selection -
i making use of custom jtable , abstracttablemodel, have encountered interesting behavior when comes highlighting/selecting rows.
alright, upon startup table looks so, good:
but unfortunately, selecting row gives me this:
occurs in 2 ways:
when row in editable "boolean" column clicked, there quick flash looks above picture before entire row highlighted.
when row divider directly below row clicked in "boolean" column. in case, table stays above picture until row selected.
the booleanrenderer
, used internally jtable
render tablemodel
values of type boolean.class
, not exhibit behavior. typical implementation conditions foreground , background colors based on default values specified current & feel. in outline, (presumedly custom) renderer needs this:
@override public component gettablecellrenderercomponent( jtable table, object value, boolean isselected, boolean hasfocus, int row, int col) { … if (isselected) { setforeground(table.getselectionforeground()); setbackground(table.getselectionbackground()); } else { setforeground(table.getforeground()); setbackground(table.getbackground()); } return …; }
a complete example seen here.
Comments
Post a Comment