void tearOff(DefaultMutableTreeNode node, Point pnt) { isDragging = false; pFrame.setCursor(Cursor.getDefaultCursor()); if(node==null) node = (DefaultMutableTreeNode)pTree.getLastSelectedPathComponent(); if(node.isLeaf()) return; TreeNode[] nPath = node.getPath(); TreeNode[] rPath = root.getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[nPath.length-rPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)nPath[i+rPath.length-1]; TreePath path = new TreePath(nPath); TreePath localPath = new TreePath(tPath); String pathString = localPath.toString(); TreePanel p = pcp.getPanelForNode(node); if (p==null) { if(pnt!=null) p = pcp.newPanel(node, pnt); else p = pcp.newPanel(node); pTree.collapsePath(localPath); } else { if (pnt!=null) p.setLocation(pnt); p.setVisible(); pTree.collapsePath(localPath); } }
void tearOff(DefaultMutableTreeNode node, Point pnt) { isDragging = false; pFrame.setCursor(Cursor.getDefaultCursor()); if(node==null) node = (DefaultMutableTreeNode)pTree.getLastSelectedPathComponent(); if(node.isLeaf()) return; TreeNode[] nPath = node.getPath(); TreeNode[] rPath = root.getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[nPath.length-rPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)nPath[i+rPath.length-1]; TreePath path = new TreePath(nPath); TreePath localPath = new TreePath(tPath); String pathString = localPath.toString(); TreePanel p = pcp.getPanelForNode(node); if (p==null) { if(pnt!=null) p = pcp.newPanel(node, pnt); else p = pcp.newPanel(node); pTree.collapsePath(localPath); } else { if (pnt!=null) p.setLocation(pnt); p.setVisible(); pTree.collapsePath(localPath); } }