Demos and Usage of javax.swing.JTree.setAnchorSelectionPath(TreePath newPath)


   1: import javax.swing.JPopupMenu;
   2: import javax.swing.JTree;
   3: import javax.swing.SwingUtilities;
   4:         ...
   5: public class JTreePopupMenuManipulator extends MouseAdapter {
   6:     public JTreePopupMenuManipulator(JTree tree,JPopupMenu popupMenu) {
   7:         m_popupMenu=popupMenu;
   8:         ...
   9:     protected void showPopup(MouseEvent event) {
  10:         final JTree tree=(JTree)event.getComponent();
  11:         final int x=event.getX();
  12:         ...
  13:                     tree.addSelectionPath(path);
  14:                 tree.setAnchorSelectionPath(path);

View Full Code Here