本文整理匯總了Java中javax.swing.JScrollBar.addAdjustmentListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JScrollBar.addAdjustmentListener方法的具體用法?Java JScrollBar.addAdjustmentListener怎麽用?Java JScrollBar.addAdjustmentListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JScrollBar
的用法示例。
在下文中一共展示了JScrollBar.addAdjustmentListener方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeImpl
import javax.swing.JScrollBar; //導入方法依賴的package包/類
@Override
void initializeImpl() {
super.initializeImpl();
final Scrollbar target = getTarget();
setLineIncrement(target.getUnitIncrement());
setPageIncrement(target.getBlockIncrement());
setValues(target.getValue(), target.getVisibleAmount(),
target.getMinimum(), target.getMaximum());
final int orientation = target.getOrientation();
final JScrollBar delegate = getDelegate();
synchronized (getDelegateLock()) {
delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
? Adjustable.HORIZONTAL
: Adjustable.VERTICAL);
delegate.addAdjustmentListener(this);
}
}
示例2: attachScrollBar
import javax.swing.JScrollBar; //導入方法依賴的package包/類
public void attachScrollBar(JScrollBar scrollBar, boolean horizontal) {
if (this.scrollBar == scrollBar) return;
if (this.scrollBar != null) detachScrollBar();
this.scrollBar = scrollBar;
this.horizontal = horizontal;
scrollBar.addAdjustmentListener(this);
scrollBar.addMouseWheelListener(this);
if (!horizontal)
InteractiveCanvasComponent.this.addMouseWheelListener(this);
}
示例3: checkScrollBar
import javax.swing.JScrollBar; //導入方法依賴的package包/類
private void checkScrollBar(AdjustmentEvent e) {
// The scroll bar listModel contains information needed to determine
// whether the viewport should be repositioned or not.
JScrollBar scrollBar = (JScrollBar) e.getSource();
BoundedRangeModel scrollBarModel = scrollBar.getModel();
int value = scrollBarModel.getValue();
int extent = scrollBarModel.getExtent();
int maximum = scrollBarModel.getMaximum();
boolean valueChanged = previousScrollBarValue != value;
boolean maximumChanged = previousScrollBarMaximum != maximum;
// Check if the user has manually repositioned the scrollbar
if (valueChanged && !maximumChanged) {
adjustScrollBar = value + extent >= maximum;
}
// Reset the "value" so we can reposition the viewport and
// distinguish between a user scroll and a program scroll.
// (ie. valueChanged will be false on a program scroll)
if (adjustScrollBar) {
// Scroll the viewport to the end.
scrollBar.removeAdjustmentListener(scrollBarAdjustmentListener);
value = maximum - extent;
scrollBar.setValue(value);
scrollBar.addAdjustmentListener(scrollBarAdjustmentListener);
}
previousScrollBarValue = value;
previousScrollBarMaximum = maximum;
}