How can I expand a JTree when I single-click on the icon of a node?

Urmila Kulkarni

The answer is: In mouseClicked() method write tree.Expand() & tree.Collapse() method. code for that:


public void mouseClicked(MouseEvent e){
  if(jTree.isCollapsed(jTree.getRowForLocation(e.getX(),e.getY()))) {
    jTree.expandRow(jTree.getRowForLocation(e.getX(),e.getY()));
  }
  else {
    jTree.collapseRow(jTree.getRowForLocation(e.getX(),e.getY()));
  }
}  //mouseclick
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact