本文整理汇总了Java中javax.swing.JTree.getRowBounds方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.getRowBounds方法的具体用法?Java JTree.getRowBounds怎么用?Java JTree.getRowBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.getRowBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeScrollPosition
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Store first visible node and its offset. Called when the view is scrolled
* by the user.
*/
private void storeScrollPosition() {
JTree tree = getJTree();
if (tree != null) {
int scrollTop = mainScrollPane.getViewport().getViewPosition().y;
int row = tree.getClosestRowForLocation(tree.getRowBounds(0).x + 1,
scrollTop);
if (row >= 0) {
TreePath path = tree.getPathForRow(row);
if (path != null) {
int offset = tree.getRowBounds(row).y - scrollTop;
visibleTreePosition = new VisibleTreePosition(
path, offset);
return;
}
} else {
return;
}
}
visibleTreePosition = null;
}
示例2: restoreScrollPosition
import javax.swing.JTree; //导入方法依赖的package包/类
/**
* Restore stored scroll position.
*/
private void restoreScrollPosition(boolean delayScrollWithMarkingDirtyRegion) {
if (visibleTreePosition != null) {
JTree tree = getJTree();
if (tree != null) {
int row = tree.getRowForPath(visibleTreePosition.getPath());
if (row != -1) {
Rectangle bounds = tree.getRowBounds(row);
if (bounds != null) {
int scrollY = bounds.y - visibleTreePosition.getOffset();
JViewport viewport = mainScrollPane.getViewport();
Rectangle rect = viewport.getViewRect();
rect.y = scrollY;
if (!rect.isEmpty()) {
JComponent view = (JComponent) viewport.getView();
if (delayScrollWithMarkingDirtyRegion) {
RepaintManager.currentManager(viewport).addDirtyRegion(
view,
rect.x, rect.x, rect.width, rect.height);
}
ignoreScrollAdjustment = true;
try {
view.scrollRectToVisible(
rect);
} finally {
ignoreScrollAdjustment = false;
}
}
}
}
}
}
}
示例3: getCellBounds
import javax.swing.JTree; //导入方法依赖的package包/类
private Rectangle getCellBounds() {
Callable<Rectangle> x = new Callable<Rectangle>() {
@Override public Rectangle call() {
JTree tree = (JTree) parent.getComponent();
return tree.getRowBounds(viewRow);
}
};
try {
return EventQueueWait.exec(x);
} catch (Exception e) {
return new Rectangle();
}
}
示例4: isVisible
import javax.swing.JTree; //导入方法依赖的package包/类
private boolean isVisible(JTree tree, int row) {
Rectangle visibleRect = tree.getVisibleRect();
Rectangle cellRect = tree.getRowBounds(row);
return SwingUtilities.isRectangleContainingRectangle(visibleRect, cellRect);
}