java - JXTreeTable - Weird cell rendering issue for certain Look and Feels -
so here's problem. have developed plugin intellij contains tool window, , part of contains tabbed pane jxtreetable this
looks great , works expected until start clicking on rows. i'll explain issue through screenshots.
- select next row
- repeat above procedure next couple of rows , end this!
urghh..puke
- now if move mouse pointer again, colors come magic!
continue moving mouse along rows..
- also @ point if mouse pointer leaves column..the view normal again (except selected row of course)
my , feel intellij dark , feel - com.intellij.ide.ui.laf.intellijlaf
, found out using system.out.println(uimanager.getlookandfeel())
if change , feel programmatically else, issue disappears. i'm not in position alter default , feel have fix issue (or bug?).
i've used hack apply different , feel jxtreetable view component, , worked great until.. open project on new window (this creates new instance of tool window new project) , hack time around works against me, setting , feel new project instance, resetting , feel default first project instance
oh , i'm using defaulttreecellrenderer
treetable.
edit: implemented custom cell renderer treetable, setting transparent when not selected (like madprogrammer suggested), issue still there.
public class customcellrenderer extends jlabel implements treecellrenderer { @override public component gettreecellrenderercomponent(jtree tree, object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasfocus) { if (selected){ setbackground(color.blue); setforeground(color.white); }else{ setforeground(color.black); setbackground(color.white); setopaque(false); } settext(value != null ? value.tostring() : "<null>"); return this; } }
there slight change in results now. lol
compare 4. above
edit 02:
so decided disable cell selection treetable using treetable.setfocusable(false)
. guess what? when click on row nothing happens. no cell selections or colour changes. once move mouse pointer next row shown above (step 2), yup same story on again. looks it's related mouse listener somewhere? idk.. driving me nuts. highly appreciated!
edit 03:
this seems laf that's giving me trouble com.intellij.ide.ui.laf.darcula.darculalaf
edit 04
so gave swingx , tried implement jtreetable component scratch, see if fix issue. managed put implementation using online source code. results interesting.
as can see issue still there unlike before, not propagate cell cell. basically, shows on current selected cell.
anyway, implementation used, contains mytreetable
class extends jtreetable
class. complete source code can found here
if instantiate jtreetable
instead of mytreetable
cell rendering issue disappears, collapse/expand feature of jtreetable
. turns flat tree. (useless!) whatever that's causing issue,
- is in
mytreetable
class - provides collapse/expand behavior tree component
after bit of debugging narrowed down following method. if remove method mytreetable
class, can't expand/collapse treetable, once it's included cell rendering issue comes back.
public boolean editcellat(int row, int column, eventobject e){ if(e instanceof mouseevent){ mouseevent me = (mouseevent)e; // if modifiers not 0 (or left mouse button), // tree may try , toggle selection, , table // try , toggle, resulting in // selection remaining same. avoid this, // dispatch when modifiers 0 (or left mouse // button). if(me.getmodifiers()==0 || me.getmodifiers()==inputevent.button1_mask){ for(int counter = getcolumncount()-1; counter>= 0; counter--){ if(getcolumnclass(counter)== treetablemodel.class){ mouseevent newme = new mouseevent (tree, me.getid(), me.getwhen(), me.getmodifiers(), me.getx()-getcellrect(0, counter, true).x, me.gety(), me.getclickcount(), me.ispopuptrigger()); tree.dispatchevent(newme); break; } } } return false; } return super.editcellat(row, column, e); }
anyway, looks bug intellij side because it's , feel specific , exists degree in both swingx , standard library jtreetable implementation. maybe i'm approaching totally wrong. still if there possible fix, please share ideas. need issue sorted out. thanks
Comments
Post a Comment