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

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

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

JTree.scrollRowToVisible介绍

暂无

代码示例

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

tree.scrollRowToVisible(row);

代码示例来源: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.max( 0, selectionRow - 10 );
   _tree.setSelectionRow( selectionRow );
   _tree.scrollRowToVisible( selectionRow );
  }
 }
} );

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

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

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

@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: 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: org.cytoscape/swing-application-impl

@Override
  public void run() {
    ignoreTreeSelectionEvents = true;
    treeTable.getTree().getSelectionModel().setSelectionPaths(paths.toArray(new TreePath[paths.size()]));
    ignoreTreeSelectionEvents = false;

    int maxRow = 0;

    for (final TreePath tp : paths) {
      final int row = treeTable.getTree().getRowForPath(tp);
      maxRow = Math.max(maxRow, row);
    }
    
    final int row = maxRow;

    treeTable.getTree().scrollRowToVisible(row);
    treeTable.repaint();
  }
});

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

private void selectMatchingRow() {
  myFilterTextField.setForeground(UIManager.getColor("TextField.foreground"));
  myJavaHierarchyTree.setSelectionRow(-1);
  // select first matching
  for (int row = 0; row < myJavaHierarchyTree.getRowCount(); row++) {
    Object o = myJavaHierarchyTree.getPathForRow(row).getLastPathComponent();
    if (o instanceof JavaElement) {
      String filterText = myFilterTextField.getText();
      if (Utils.patternMatch((JavaElement)o, filterText, 
          filterText.toLowerCase())) 
      {
        myJavaHierarchyTree.setSelectionRow(row);
        myJavaHierarchyTree.scrollRowToVisible(row);
        return;
      }
    }
  }
  myFilterTextField.setForeground(Color.RED);
}

代码示例来源:origin: com.fifesoft.rtext/fife.common

if (htn.getUrl()!=null && htn.getUrl().equals(url)) {
  tocTree.setSelectionRow(i);
  tocTree.scrollRowToVisible(i);
  return;

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

tree.scrollRowToVisible(row);

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

@Override
protected void setSelectedIndex(int index, boolean incremental) {
  if (!isRecursive()) {
    if (incremental) {
      ((JTree) _component).addSelectionInterval(index, index);
    }
    else {
      ((JTree) _component).setSelectionRow(index);
    }
    ((JTree) _component).scrollRowToVisible(index);
  }
  else {
    Object elementAt = getElementAt(index);
    if (elementAt instanceof TreePath) { // else case should never happen
      TreePath path = (TreePath) elementAt;
      if (incremental) {
        ((JTree) _component).addSelectionPath(path);
      }
      else {
        ((JTree) _component).setSelectionPath(path);
      }
      ((JTree) _component).scrollPathToVisible(path);
    }
  }
}

相关文章

JTree类方法