This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree" Watch "JTree" New topic
Author

JTree

Carol Chen
Greenhorn

Joined: Jun 10, 2001
Posts: 19
Hi everyone,
I build a swing program with JTree. I don't know how to change the selected node background color when mouse right clicked.
Hope to get the answer soon.
Thanks
Carol
sihem merah
Greenhorn

Joined: Aug 07, 2001
Posts: 2
Hi!
Here is a part of my method mouseClicked(MouseEvent e) in the class implementing MouseListener:
public void mouseClicked(MouseEvent e)
{
if ((e.getModifiers() & InputEvent.BUTTON3_MASK)== InputEvent.BUTTON3_MASK)
{
Point pLoc = e.getPoint();
TreePath destPath = tree.getPathForLocation(pLoc.x,pLoc.y);
if (destPath!=null)
tree.setSelectionPath(destPath);
}

It is very easy.
Hope it will help you.
Ciao!
 
Don't get me started about those stupid light bulbs.
 
subject: JTree
 
Similar Threads
JTree
JTree
JTree
JTree
JTree