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

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

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

JTree.scrollRectToVisible介绍

暂无

代码示例

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

/** Make a path visible.
* @param path the path
*/
private void showPathWithoutExpansion (TreePath path) {
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null) { //PENDING
    tree.scrollRectToVisible(rect);
  }
}

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

/** Make a path visible.
* @param path the path
*/
private void showPathWithoutExpansion (TreePath path) {
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null) { //PENDING
    tree.scrollRectToVisible(rect);
  }
}

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

public void run() {
    tree.scrollRectToVisible(tree.getRowBounds(selectedRow));
  }
}

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
@Nonnull private static Point scrollToTreePath(@Nonnull JTree tree, @Nonnull TreePath path,
                        @Nonnull JTreeLocation location) {
 Pair<Rectangle, Point> boundsAndCoordinates = location.pathBoundsAndCoordinates(tree, path);
 tree.scrollRectToVisible(boundsAndCoordinates.first);
 return checkNotNull(boundsAndCoordinates.second);
}

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
@Nonnull private static Point scrollToVisible(@Nonnull JTree tree, int row, @Nonnull JTreeLocation location) {
 Pair<Rectangle, Point> boundsAndCoordinates = location.rowBoundsAndCoordinates(tree, row);
 tree.scrollRectToVisible(boundsAndCoordinates.first);
 return checkNotNull(boundsAndCoordinates.second);
}

代码示例来源:origin: nl.cloudfarming.client/nbtaskfocus-core

public void scrollToNode(Node n) {
  TreeNode tn = Visualizer.findVisualizer(n);
  if (tn == null) {
    return;
  }
  TreeModel model = tree.getModel();
  if (!(model instanceof DefaultTreeModel)) {
    return;
  }
  TreePath path = new TreePath(((DefaultTreeModel) model).getPathToRoot(tn));
  Rectangle r = tree.getPathBounds(path);
  if (r != null) {
    tree.scrollRectToVisible(r);
  }
}

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

void scrollTreeToVisible(TreePath path, TreeNode child) {
  Rectangle base = tree.getVisibleRect();
  Rectangle b1 = tree.getPathBounds(path);
  Rectangle b2 = tree.getPathBounds(new TreePath(treeModel.getPathToRoot(child)));
  if ((base != null) && (b1 != null) && (b2 != null)) {
    tree.scrollRectToVisible(new Rectangle(base.x, b1.y, 1, b2.y - b1.y + b2.height));
  }
}

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

void scrollTreeToVisible(TreePath path, TreeNode child) {
  Rectangle base = tree.getVisibleRect();
  Rectangle b1 = tree.getPathBounds(path);
  Rectangle b2 = tree.getPathBounds(new TreePath(treeModel.getPathToRoot(child)));
  if (base != null && b1 != null && b2 != null) {
    tree.scrollRectToVisible(new Rectangle(base.x, b1.y, 1, b2.y - b1.y + b2.height));
  }
}

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

void scrollTreeToVisible(TreePath path, TreeNode child) {
  Rectangle base = tree.getVisibleRect();
  Rectangle b1 = tree.getPathBounds(path);
  Rectangle b2 = tree.getPathBounds(new TreePath(treeModel.getPathToRoot(child)));
  if (base != null && b1 != null && b2 != null) {
    tree.scrollRectToVisible(new Rectangle(base.x, b1.y, 1, b2.y - b1.y + b2.height));
  }
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

private void makeVisible(ComponentTreeNode node) {
  // Make sure the user can see the new node, but don't scroll to
  // right.
  TreePath treePath = new TreePath(node.getPath());
  Rectangle bounds = ComponentSelector.this.tree.getPathBounds(treePath);
  if (bounds != null) {
    // Prevent right scroll.
    bounds.x = 0;
    bounds.width = 0;
    this.tree.scrollRectToVisible(bounds);
  } else {
    // null during the initialization.
    this.tree.scrollPathToVisible(treePath);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-hints-analyzer

private void showPathWithoutExpansion(TreePath path) {
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null && getWidth() > 0 && getHeight() > 0 ) {
    tree.scrollRectToVisible(rect);
  }
}

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

/** Expand the given path and makes it visible.
* @param path the path
*/
protected void showPath(TreePath path) {
  tree.makeVisible(path);
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null) {
    rect.width += rect.x;
    rect.x = 0;
    tree.scrollRectToVisible(rect);
  }
  tree.setSelectionPath(path);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelutil

private void showPathWithoutExpansion(TreePath path) {
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null && getWidth() > 0 && getHeight() > 0) {
    tree.scrollRectToVisible(rect);
  }
}

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

/** Expand the given path and makes it visible.
* @param path the path
*/
protected void showPath(TreePath path) {
  tree.makeVisible(path);
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null) {
    rect.width += rect.x;
    rect.x = 0;
    tree.scrollRectToVisible(rect);
  }
  tree.setSelectionPath(path);
}

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

/** Expand the given path and makes it visible.
* @param path the path
*/
protected void showPath(TreePath path) {
  tree.makeVisible(path);
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null) {
    rect.width += rect.x;
    rect.x = 0;
    tree.scrollRectToVisible(rect);
  }
  tree.setSelectionPath(path);
}

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

/** Make a path visible.
* @param path the path
*/
private void showPathWithoutExpansion(TreePath path) {
  Rectangle rect = tree.getPathBounds(path);
  if (rect != null) { //PENDING
    TreeUI tmp = tree.getUI();
    int correction = 0;
    if (tmp instanceof BasicTreeUI) {
      correction = ((BasicTreeUI) tmp).getLeftChildIndent();
      correction += ((BasicTreeUI) tmp).getRightChildIndent();
    }
    rect.x = Math.max(0, rect.x - correction);
    if (rect.y >= 0) { //#197514 - do not scroll to negative y values
      tree.scrollRectToVisible(rect);
    }
  }
}

代码示例来源:origin: triplea-game/triplea

private void navigateTo(final TreeNode target) {
 final TreeNode[] nodes = ((DefaultMutableTreeNode) target).getPath();
 final TreePath newPath = new TreePath(nodes);
 tree.expandPath(newPath);
 tree.setSelectionPath(newPath);
 final int row = tree.getRowForPath(newPath);
 if (row == -1) {
  return;
 }
 final Rectangle bounds = tree.getRowBounds(row);
 if (bounds == null) {
  return;
 }
 // scroll to the far left
 bounds.x = 0;
 bounds.width = 10;
 tree.scrollRectToVisible(bounds);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-outline

public void scrollToNodes(Node[] nodes) {
  TreePath[] treePaths = getTreePathsForNodes(nodes);
  Rectangle rect = new Rectangle();
  
  if (areTreePathsVisible(treePaths)) {
    return;
  }
  
  for (int i = 0; i < treePaths.length; i++) {
    Rectangle bounds = tree.getPathBounds(treePaths[i]);
    if (bounds == null) {
      ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
          new NullPointerException("No bounds for treePath=" + treePaths[i])); // NOI18N
    } else {
      rect.add(bounds);
    }
  }
  
  if (!rect.isEmpty()) {
    tree.scrollRectToVisible(rect);
  }
}

代码示例来源:origin: gurkenlabs/litiengine

this.tree.scrollRectToVisible(bounds);
return true;

代码示例来源:origin: triplea-game/triplea

final Rectangle rect = tree.getPathBounds(path);
 rect.setRect(0, rect.getY(), rect.getWidth(), rect.getHeight());
 tree.scrollRectToVisible(rect);
} else {
 if (!mouseWasOverPanel) {

相关文章

JTree类方法