javax.swing.JTree.getSelectionPath()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(277)

本文整理了Java中javax.swing.JTree.getSelectionPath()方法的一些代码示例,展示了JTree.getSelectionPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.getSelectionPath()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:getSelectionPath

JTree.getSelectionPath介绍

暂无

代码示例

代码示例来源:origin: pentaho/mondrian

public Object getParentObject() {
  TreePath tPath = tree.getSelectionPath();
  if ((tPath != null) && (tPath.getParentPath() != null)) {
    return tPath.getParentPath().getLastPathComponent();
  }
  return null;
}

代码示例来源:origin: pentaho/mondrian

protected void addAnnotations(ActionEvent evt) {
  TreePath tpath = null;
  tpath = getTreePath(evt);
  Object path = tree.getSelectionPath().getLastPathComponent();
  refreshTree(tree.getSelectionPath());

代码示例来源:origin: pentaho/mondrian

protected void arrowButtonDownAction(ActionEvent evt) {
  TreePath tpath = tree.getSelectionPath();
  if (tpath != null) {
    Object current = tpath.getLastPathComponent();
    Object child = tree.getModel().getChild(current, 0);
    if (child != null) {
      int objCnt = 2;
      while (parentpath != null) {
        Object po = parentpath.getLastPathComponent();
        treeObjs[objCnt] = po;
        objCnt += 1;

代码示例来源:origin: pentaho/mondrian

protected void addAnnotation(ActionEvent evt) {
  TreePath tpath = null;
  tpath = getTreePath(evt);
  Object path = tree.getSelectionPath().getLastPathComponent();
  if (!(path instanceof MondrianGuiDef.Annotations)) {
    JOptionPane.showMessageDialog(
  tree.setSelectionPath(tpath.pathByAddingChild(annotation));
  refreshTree(tree.getSelectionPath());
  setTableCellFocus(0);

代码示例来源:origin: pentaho/mondrian

void delete(TreePath tpath) {
  Object child = tpath.getLastPathComponent(); // to be deleted
  Object nextSibling = null;
  Object prevSibling = null;
    tree.setSelectionPath(tpath.getParentPath());
  refreshTree(tree.getSelectionPath());

代码示例来源:origin: pentaho/mondrian

TreePath tpath = tree.getSelectionPath();
if (tpath != null) {
  Object value = tpath.getLastPathComponent();
  TreePath parentpath = tpath.getParentPath();
  if (parentpath != null) {
    Object parent = parentpath.getLastPathComponent();
    if (parent instanceof MondrianGuiDef.Hierarchy) {
      ((MondrianGuiDef.Hierarchy) parent).relation = relationObj;

代码示例来源:origin: org.wildfly.core/wildfly-cli

/**
 * Get the node that has been selected by the user, or null if
 * nothing is selected.
 * @return The node or <code>null</code>
 */
public ManagementModelNode getSelectedNode() {
  if (tree.getSelectionPath() == null) return null;
  return (ManagementModelNode)tree.getSelectionPath().getLastPathComponent();
}

代码示例来源:origin: net.sf.sfac/sfac-core

public Object getSelectedObject() {
  Object selected = null;
  if (theTree != null) {
    TreePath selectionPath = theTree.getSelectionPath();
    selected = (selectionPath == null) ? null : selectionPath.getLastPathComponent();
  }
  return selected;
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

@Override
 public void keyReleased(KeyEvent e) {
  TreePath path = sidebarTree.getSelectionPath();
  if (path != null) {
   handleTreeSelection((DefaultMutableTreeNode) path.getLastPathComponent());
  }
 }
});

代码示例来源:origin: org.jrobin/jrobin

private RrdNode getSelectedRrdNode() {
  TreePath path = mainTree.getSelectionPath();
  if (path != null) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    Object obj = node.getUserObject();
    if (obj instanceof RrdNode) {
      return (RrdNode) obj;
    }
  }
  return null;
}

代码示例来源:origin: org.fusesource.rrd4j/rrd4j

private RrdNode getSelectedRrdNode() {
  TreePath path = mainTree.getSelectionPath();
  if (path != null) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    Object obj = node.getUserObject();
    if (obj instanceof RrdNode) {
      return (RrdNode) obj;
    }
  }
  return null;
}

代码示例来源:origin: uk.org.mygrid.taverna.scufl.scufl-ui-components/workflow-input-panel

void updatePanel() {
  if (portTree.getSelectionPath().getLastPathComponent() instanceof PanelTreeNode) {
    PanelTreeNode node = (PanelTreeNode) portTree.getSelectionPath()
        .getLastPathComponent();
    splitter.setRightComponent(node.getPanel());
  }
}

代码示例来源:origin: com.mgmtp.jfunk/jfunk-core

@Override
public void mouseClicked(final MouseEvent e) {
  if (!e.isPopupTrigger() && e.getClickCount() == 2) {
    if (tree.getModel().isLeaf(tree.getSelectionPath().getLastPathComponent())) {
      runScripts();
    }
  }
}

代码示例来源:origin: cpesch/RouteConverter

public static CategoryTreeNode getSelectedCategoryTreeNode(JTree tree) {
  TreePath treePath = tree.getSelectionPath();
  // if there is no selected root take the local root
  Object value = treePath != null ?
      treePath.getLastPathComponent() :
      tree.getModel().getChild(tree.getModel().getRoot(), 0);
  if (!(value instanceof CategoryTreeNode))
    return null;
  return (CategoryTreeNode) value;
}

代码示例来源:origin: it.geosolutions.jaiext.utilities/jt-utilities

public void valueChanged(TreeSelectionEvent e)
{
  final TreePath selectedpath = imageTree.getSelectionPath();
  if (selectedpath == null)
  {
    imageTree.setSelectionRow(0);
  }
  RenderedImage image = (RenderedImage) imageTree.getSelectionPath().getLastPathComponent();
  imageInfo.setImage(image);
}

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

public void actionPerformed(ActionEvent evt)
  {
    TreePath path = resultTree.getSelectionPath();
    DefaultMutableTreeNode operNode = (DefaultMutableTreeNode)path.getLastPathComponent();
    expandAllNodes(operNode);
  }
}//}}}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

public void keyPressed(KeyEvent e) {
  if (e.getKeyCode() != 10) return; // ENTER pressed?
  TreePath path = tree.getSelectionPath();
  if (path == null) return;
  Object node = path.getLastPathComponent ();
  LanguagesNavigatorModel model = (LanguagesNavigatorModel) tree.getModel ();
  model.show (node);
}

代码示例来源:origin: nroduit/Weasis

public Path getCurrentDir() {
  final TreePath path = tree.getSelectionPath();
  if (path != null) {
    return ((TreeNode) path.getLastPathComponent()).getNodePath();
  }
  return null;
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

@Override
  protected Transferable createTransferable(JComponent c) {

    JTree tree = (JTree) c;

    TreePath path = tree.getSelectionPath();

    DefaultMutableTreeNode node =
        (DefaultMutableTreeNode) path.getLastPathComponent();

    return new ObjectTransferable(node.getUserObject());
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

public void valueChanged(TreeSelectionEvent e) {
    TreePath treePath = tree.getSelectionPath();
    if (treePath != null) {
      getTextComponent().setText("" + treePath.getLastPathComponent());
      highlightCompletedText(0);
    }
    else {
      getTextComponent().setText("");
    }
  }
});

相关文章

JTree类方法