aspose file tools*
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
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree
 
Similar Threads
JTree
JTree
JTree
JTree
JTree