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

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

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

JTree.setSelectionRow介绍

暂无

代码示例

代码示例来源:origin: INRIA/spoon

@Override
public void mousePressed(MouseEvent e) {
  getJTree().setSelectionRow(
      getJTree().getClosestRowForLocation(e.getX(), e.getY()));
  maybeShowPopup(e);
}

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

@Override
  public void mousePressed(MouseEvent e) {
    int row = tree.getClosestRowForLocation(e.getX(), e.getY());
    if (row != -1) {
      tree.setSelectionRow(row);
    }
  }
});

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

@Override
  public void actionPerformed(ActionEvent e) {
    int row = arvoreExemplos.getSelectionRows()[0];
    arvoreExemplos.setSelectionRow(Math.max(0,row-1));
  }
};

代码示例来源:origin: org.icepdf.os/icepdf-viewer

@Override
  public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e)) {
      int row = commentTree.getClosestRowForLocation(e.getX(), e.getY());
      commentTree.setSelectionRow(row);
      contextMenu.show(e.getComponent(), e.getX(), e.getY());
    }
  }
}

代码示例来源:origin: nu.zoom/eon2

private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
      int row = tree.getRowForLocation(e.getX(), e.getY());
      if (tree.getSelectionCount() < 2) {
        tree.setSelectionRow(row);
      }
      popupMenu.show(e.getComponent(), e.getX(), e.getY());
    }
  }
}

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

protected void showPopup (MouseEvent e) {
      int selRow = tree.getRowForLocation(e.getX(), e.getY());
      if (!tree.isRowSelected(selRow)) {
        tree.setSelectionRow(selRow);
      }
    }
};

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

@Override
    protected void showPopup(MouseEvent e) {
      int selRow = tree.getClosestRowForLocation(e.getX(), e.getY());
      if (!tree.isRowSelected(selRow)) {
        tree.setSelectionRow(selRow);
      }
    }
  };

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

protected void showPopup (MouseEvent e) {
      int selRow = tree.getRowForLocation(e.getX(), e.getY());
      if (!tree.isRowSelected(selRow)) {
        tree.setSelectionRow(selRow);
      }
    }
};

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

@Override
  public void actionPerformed(ActionEvent e) {
    int row = arvoreExemplos.getSelectionRows()[0];
    arvoreExemplos.setSelectionRow(Math.min(row+1, arvoreExemplos.getRowCount()-1));
  }
};

代码示例来源:origin: fr.ifremer/isis-fish

protected void createFisheryRegionTree() {
  $objectMap.put("fisheryRegionTree", fisheryRegionTree = new JTree());
  
  fisheryRegionTree.setName("fisheryRegionTree");
  fisheryRegionTree.setRootVisible(true);
  fisheryRegionTree.setSelectionRow(0);
  fisheryRegionTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__fisheryRegionTree"));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

static void firstRow(JTree tree) {
  int rowCount = tree.getRowCount();
  if (rowCount > 0) {
    tree.setSelectionRow(0);
    scrollTreeToSelectedRow(tree);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

static void lastRow(JTree tree) {
  int rowCount = tree.getRowCount();
  if (rowCount > 0) {
    tree.setSelectionRow(rowCount - 1);
    scrollTreeToSelectedRow(tree);
  }
}

代码示例来源: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: fr.ifremer/isis-fish

protected void createFisheryRegionTree() {
  $objectMap.put("fisheryRegionTree", fisheryRegionTree = new JTree());
  
  fisheryRegionTree.setName("fisheryRegionTree");
  fisheryRegionTree.setRootVisible(true);
  fisheryRegionTree.setRowHeight(0);
  fisheryRegionTree.setSelectionRow(0);
  fisheryRegionTree.addTreeSelectionListener(JAXXUtil.getEventListener(TreeSelectionListener.class, "valueChanged", this, "doValueChanged__on__fisheryRegionTree"));
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

@Override
 public void run()
 {
  _tree.setModel( new DefaultTreeModel( beanTree1 ) );
  _tree.setSelectionRow( 0 );
  _tree.revalidate();
  _tree.repaint();
 }
} );

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

@Override
 public void actionPerformed( ActionEvent e )
 {
  int[] selectionRows = _tree.getSelectionRows();
  if( selectionRows != null )
  {
   int selectionRow = selectionRows[0];
   selectionRow = Math.min( _tree.getRowCount() - 1, selectionRow + 10 );
   _tree.setSelectionRow( selectionRow );
   _tree.scrollRowToVisible( selectionRow );
  }
 }
} );

代码示例来源:origin: net.openhft/spoon-core

public void mousePressed(MouseEvent e) {
  getJTree().setSelectionRow(
      getJTree().getClosestRowForLocation(e.getX(), e.getY()));
  maybeShowPopup(e);
}

代码示例来源:origin: pentaho/pentaho-reporting

public void updateConfiguration( final HierarchicalConfiguration configuration ) {
 this.configuration = configuration;
 treeModel.updateConfiguration();
 // expand out the tree and select the first node.
 for ( int i = 0; i < tree.getRowCount(); i++ ) {
  tree.expandRow( i );
 }
 tree.setSelectionRow( 1 );
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core

static void closeProject(ActionEvent e) {
    GuiPackage guiPackage = GuiPackage.getInstance();

    guiPackage.clearTestPlan();
    JTree tree = guiPackage.getTreeListener().getJTree();
    tree.setSelectionRow(0);
    FocusRequester.requestFocus(tree);
    FileServer.getFileServer().setScriptName(null);
    ActionRouter.getInstance().actionPerformed(new ActionEvent(e.getSource(), e.getID(), ActionNames.ADD_ALL));
  }
}

代码示例来源:origin: com.google.code.findbugs/findbugs

@Override
  public void actionPerformed(ActionEvent evt) {
    if (!mainFrame.canNavigateAway()) { return; }
    new NewFilterFromBug(new FilterFromBugPicker(currentSelectedBugLeaf.getBug(),
        Arrays.asList(mainFrame.getAvailableSortables())),
        new ApplyNewFilter(mainFrame.getProject().getSuppressionFilter(),
            PreferencesFrame.getInstance(),
            new FilterActivityNotifier()));
    mainFrame.setProjectChanged(true);
    mainFrame.getTree().setSelectionRow(0); // Selects the top of the Jtree so the CommentsArea syncs up.
  }
});

相关文章

JTree类方法