Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whats the best way to change background of treeNode in JTree

 
Ravi Sathish
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings Ranchers,

I'm trying to change the background of a treeNode to get a hovering effect on mouseOver(); evrything seems to work so far...except I'm updating my whole tree UI; this is causing flickering of my cursor.

Is there another way of changing the background of tree node without whole tree updateUI() ?



I would appreciate any suggestions/solutions/workarounds.

TIA
 
Craig Wood
Ranch Hand
Posts: 1535
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ravi Sathish
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Craig,

Actually your solution is neat especially if selections are based on MouseMotions. I should have been clearer in my problem description and saved you some trouble.

Unfortunately my tree is bit more complicated:
1> I select a node only on single click; I have TreeSelectionListener there
2> I do something more on double-Click; so I need a MouseAdapter
3> I need a hovering effect under drag & drop; I dont want to select the node unless the actual drop happens

Nevertheless I found tree.getRowForLocation(e.getX(), e.getY() helpful ; I realized that the rectangle sorrounding a path can be found using getPathBounds.



Hope it helps somebody looking to achieve a hovering Effect.

Ravi

[ August 30, 2005: Message edited by: Ravi Sathish ]
[ August 30, 2005: Message edited by: Ravi Sathish ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic