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

enter image description here

looks great , works expected until start clicking on rows. i'll explain issue through screenshots.

  1. row selected

    enter image description here

    1. move mouse pointer next row

enter image description here

  1. select next row

enter image description here

  1. repeat above procedure next couple of rows , end this!

enter image description here

urghh..puke

  1. now if move mouse pointer again, colors come magic!

enter image description here

continue moving mouse along rows.. enter image description here

  1. also @ point if mouse pointer leaves column..the view normal again (except selected row of course)

enter image description here

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

enter image description here

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

source: https://github.com/jetbrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/darculalaf.java

edit 04

so gave swingx , tried implement jtreetable component scratch, see if fix issue. managed put implementation using online source code. results interesting.

enter image description here

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,

  1. is in mytreetable class
  2. 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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -