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

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

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

JTree.getSelectionPaths介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

TreePath[] paths = tree.getSelectionPaths();
if(paths != null) {

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

public void valueChanged(TreeSelectionEvent treeSelectionEvent) {
    if (this.tree.getSelectionPaths() != null
      && this.tree.getSelectionPaths().length > 0)
    {
      selectedTreePaths =
        this.tree.getSelectionModel().getSelectionPaths();
    }
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * {@inheritDoc}
 * <p>
 * 
 * Overridden to always return a not-null array (following SwingX
 * convention).
 */
@Override
public TreePath[] getSelectionPaths() {
  TreePath[] paths = super.getSelectionPaths();
  return paths != null ? paths : EMPTY_TREEPATH_ARRAY; 
}

代码示例来源:origin: org.junit/com.springsource.junit

/**
 * Returns the selected test or null if multiple or none is selected
 */
public Test getSelectedTest() {
  TreePath[] paths= fTree.getSelectionPaths();
  if (paths != null && paths.length == 1)
    return (Test)paths[0].getLastPathComponent();
  return null;
}

代码示例来源:origin: sdedit/sdedit

public Object[] getSelectedObjects() {
  TreePath[] paths = tree.getSelectionPaths();
  Object[] objects = new Object[paths.length];
  for (int i = 0; i < paths.length; i++) {
    objects[i] = paths[i].getLastPathComponent();
  }
  return objects;
}

代码示例来源:origin: kaikramer/keystore-explorer

private X509Certificate getSelectedCertificate() {
  TreePath[] selections = jtrHierarchy.getSelectionPaths();
  if (selections == null) {
    return null;
  }
  return (X509Certificate) ((DefaultMutableTreeNode) selections[0].getLastPathComponent()).getUserObject();
}

代码示例来源:origin: undera/jmeter-plugins

private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonAddActionPerformed
{//GEN-HEADEREND:event_jButtonAddActionPerformed
  TreePath[] paths = jTreeGraph1.getSelectionPaths();
  if (paths != null) {
    addItemsToComposite(paths);
  }
}//GEN-LAST:event_jButtonAddActionPerformed

代码示例来源:origin: undera/jmeter-plugins

private void jButtonRemoveActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonRemoveActionPerformed
{//GEN-HEADEREND:event_jButtonRemoveActionPerformed
  TreePath[] paths = jTreeGraph2.getSelectionPaths();
  if (paths != null) {
    removeItemFromComposite(paths);
  }
}//GEN-LAST:event_jButtonRemoveActionPerformed

代码示例来源:origin: org.scijava/scijava-ui-swing

private Stream<Item> getSelectedItems() {
  TreePath[] selectionPaths = tree.getSelectionPaths();
  if (selectionPaths == null) return Collections.<Item> emptyList().stream();
  return Stream.of(selectionPaths).map(path -> getItem(
    (DefaultMutableTreeNode) path.getLastPathComponent()));
}

代码示例来源:origin: org.languagetool/languagetool-gui-commons

@Override
public void keyPressed(KeyEvent e) {
 if (e.getKeyCode() == KeyEvent.VK_SPACE) {
  TreePath[] paths = tree.getSelectionPaths();
  if (paths != null) {
   for (TreePath path : paths) {
    handle(path);
   }
  }
 }
}

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-base-swing

public void actionPerformed(ActionEvent e)
  {
    TreePath[]    paths    = tree.getSelectionPaths();
    for(int i=0; paths!=null && i<paths.length; i++)
    {
      ((ISwingTreeNode)paths[i].getLastPathComponent()).refresh(false);
    }
  }
};

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-base-swing

public void actionPerformed(ActionEvent e)
  {
    TreePath[]    paths    = tree.getSelectionPaths();
    for(int i=0; paths!=null && i<paths.length; i++)
    {
      ((ISwingTreeNode)paths[i].getLastPathComponent()).refresh(true);
    }
  }
};

代码示例来源:origin: cytoscape/application

public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    selectedTreePaths = tree.getSelectionPaths();
  } // valueChanged
} // inner class MyTreeSelectionListener

代码示例来源:origin: undera/jmeter-plugins

private void jTreeGraph1MouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jTreeGraph1MouseClicked
{//GEN-HEADEREND:event_jTreeGraph1MouseClicked
  if (evt.getClickCount() == 2) {
    TreePath[] paths = jTreeGraph1.getSelectionPaths();
    if (paths != null && paths.length == 1) {
      if (paths[0].getPath().length == 3) {
        addItemsToComposite(paths);
      }
    }
  }
}//GEN-LAST:event_jTreeGraph1MouseClicked

代码示例来源:origin: undera/jmeter-plugins

private void jTreeGraph2MouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jTreeGraph2MouseClicked
{//GEN-HEADEREND:event_jTreeGraph2MouseClicked
  if (evt.getClickCount() == 2) {
    TreePath[] paths = jTreeGraph2.getSelectionPaths();
    if (paths != null && paths.length == 1) {
      if (paths[0].getPath().length == 3) {
        removeItemFromComposite(paths);
      }
    }
  }
}//GEN-LAST:event_jTreeGraph2MouseClicked

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

public void treeCollapsed(TreeExpansionEvent event) {
    TreePath[] selectedPaths = tree.getSelectionPaths();
    fireTableDataChanged();
    tree.setSelectionPaths(selectedPaths);
  }
});

代码示例来源:origin: sdedit/sdedit

public void restoreSelections(PathIdenter identer, List<String> selections) {
  tree.removeSelectionPaths(tree.getSelectionPaths());
  for (String selection : selections) {
    TreePath path = identer.getPath(selection);
    if (path != null) {
      tree.addSelectionPath(path);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void treeStructureChanged(TreeModelEvent e) {
  // bugfix #23757, store selection paths
  tps = tree.getSelectionPaths ();
  
  // bugfix #30355, don't restore selection when the tree root changed
  // (see javadoc TreeModelListener.treeStructureChanged)
  if (e.getPath ().length == 1 && !e.getTreePath ().equals (e.getPath ()[0])) {
    tps = null;
  }
  
  delayedUpdateNodes(e);
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

public void treeStructureChanged(TreeModelEvent e) {
  // bugfix #23757, store selection paths
  tps = tree.getSelectionPaths();
  // bugfix #30355, don't restore selection when the tree root changed
  // (see javadoc TreeModelListener.treeStructureChanged)
  if ((e.getPath().length == 1) && !e.getTreePath().equals(e.getPath()[0])) {
    tps = null;
  }
  delayedUpdateNodes(e);
}

代码示例来源:origin: org.zaproxy/zap

@Override
protected void performAction() {
  File file = super.getOutputFile();
  if (file == null) {
    return;
  }
  JTree siteTree = extension.getView().getSiteTreePanel().getTreeSite();
  super.writeURLs(file, this.getOutputSet(siteTree.getSelectionPaths()));
}

相关文章

JTree类方法