本文整理汇总了Java中javax.swing.JViewport.getViewSize方法的典型用法代码示例。如果您正苦于以下问题:Java JViewport.getViewSize方法的具体用法?Java JViewport.getViewSize怎么用?Java JViewport.getViewSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JViewport
的用法示例。
在下文中一共展示了JViewport.getViewSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateThird
import javax.swing.JViewport; //导入方法依赖的package包/类
public void validateThird() {
JViewport viewport = this.pane.getViewport();
JScrollBar scroller = this.pane.getHorizontalScrollBar();
if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
throw new Error("unexpected component orientation");
}
int value = scroller.getValue();
if (value != 0) {
throw new Error("unexpected scroll value");
}
int extent = viewport.getExtentSize().width;
if (extent != scroller.getVisibleAmount()) {
throw new Error("unexpected visible amount");
}
int size = viewport.getViewSize().width;
if (size != scroller.getMaximum()) {
throw new Error("unexpected maximum");
}
int pos = size - extent - value;
if (pos != viewport.getViewPosition().x) {
throw new Error("unexpected position");
}
}
示例2: adjustTreeScrollBar
import javax.swing.JViewport; //导入方法依赖的package包/类
private void adjustTreeScrollBar(int treeViewWidth) {
DebugTreeView tView = getTreeView();
if (tView == null) {
scrollBarPanel.setVisible(false);
return;
}
JViewport viewport = tView.getViewport();
Point point = viewport.getViewPosition();
if (point.y < 0) {
viewport.setViewPosition(new Point(point.x, 0));
}
Dimension viewSize = viewport.getExtentSize();
Dimension treeSize = viewport.getViewSize();
if (treeViewWidth < 0) {
treeViewWidth = treeSize.width;
}
int unitHeight = tView.getUnitHeight();
if (unitHeight > 0) {
JScrollBar sbar = mainScrollPane.getVerticalScrollBar();
if (sbar.getUnitIncrement() != unitHeight) {
sbar.setUnitIncrement(unitHeight);
}
}
if (treeViewWidth <= viewSize.width) {
scrollBarPanel.setVisible(false);
} else {
treeScrollBar.setMaximum(treeViewWidth);
treeScrollBar.setVisibleAmount(viewSize.width);
if (unitHeight > 0) {
treeScrollBar.setUnitIncrement(unitHeight / 2);
}
treeScrollBar.setBlockIncrement(viewSize.width);
scrollBarPanel.setVisible(true);
} // else
}