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:

enter image description here

but unfortunately, selecting row gives me this:
enter image description here
occurs in 2 ways:

  1. when row in editable "boolean" column clicked, there quick flash looks above picture before entire row highlighted.

  2. 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

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -