本文整理匯總了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);
}