本文整理汇总了Java中javax.swing.JScrollBar.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollBar.setValue方法的具体用法?Java JScrollBar.setValue怎么用?Java JScrollBar.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollBar
的用法示例。
在下文中一共展示了JScrollBar.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if (source == moreButton) {
ConditionPanel comp = addCondition(true, null);
JScrollBar vsb = conditionsScrollPane.getVerticalScrollBar();
vsb.setValue(vsb.getMaximum());
comp.focusPropertyCombo();
} else if (source == fewerButton) {
conditionsPanel.remove(conditionsPanel.getComponentCount() - 1);
invalidate();
getParent().validate();
repaint();
}
updateSensitivity();
putClientProperty(FilterCondition.PROP_VALUE_VALID, Boolean.valueOf(isValueValid()));
}
示例2: doZoom
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void doZoom( Point p, double factor ) {
Rectangle rect = getVisibleRect();
double x = p.getX() / zoom;
double y = p.getY() / zoom;
double w = rect.getWidth();
double h = rect.getHeight();
zoom *= factor;
int newX = (int) (x*zoom - w*.5d);
int newY = (int) (y*zoom - h*.5d);
invalidate();
scrollPane.validate();
JScrollBar sb = scrollPane.getHorizontalScrollBar();
sb.setValue(newX);
sb = scrollPane.getVerticalScrollBar();
sb.setValue(newY);
repaint();
}
示例3: appendText
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void appendText(final String str) {
if (!EventQueue.isDispatchThread()) {
throw new IllegalStateException("Method must be called on EDT!");
}
final JScrollBar scrollBar;
JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this);
if (scrollPane == null) {
scrollBar = null;
} else {
JScrollBar sb = scrollPane.getHorizontalScrollBar();
if (sb.getValue() + SCROLL_THRESHOLD >= sb.getMaximum()) {
scrollBar = sb;
} else {
scrollBar = null;
}
}
append(str);
if (scrollBar != null) {
scrollBar.setValue(scrollBar.getMaximum());
}
}
示例4: rotate
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* Not Implemented.
*/
public void rotate(int direction) {
Dimension dim = getPreferredSize();
Rectangle rect = getVisibleRect();
if(dim.width>rect.width) rect.width = dim.width;
if(dim.height>rect.height) rect.height = dim.height;
if(proj instanceof CylindricalProjection ) return;
rotation += (direction>0) ? 1:3;
rotation &= 0x3;
JScrollBar hsb = scrollPane.getHorizontalScrollBar();
int x = hsb.getValue();
JScrollBar vsb = scrollPane.getVerticalScrollBar();
int y = vsb.getValue();
if(direction>0) {
hsb.setValue(dim.height - rect.height - y);
vsb.setValue(x);
} else {
hsb.setValue(y);
vsb.setValue(dim.width -rect.width - x);
}
revalidate();
repaint();
}
示例5: doZoom
import javax.swing.JScrollBar; //导入方法依赖的package包/类
void doZoom( Point p, double factor ) {
if( scPane == null || ( tracksWidth && tracksHeight ))return;
Insets ins = axes.getInsets();
Rectangle rect = getVisibleRect();
double x = (double)(p.x-ins.left) / zoom;
double y = (double)(p.y-ins.top) / zoom;
double w = (double) (rect.width - ins.left - ins.right);
double h = (double) (rect.height - ins.top - ins.bottom);
zoom *= factor;
int newX = (int) (x*zoom - w*.5d);
int newY = (int) (y*zoom - h*.5d);
invalidate();
scPane.validate();
JScrollBar sb;
if(!tracksWidth) {
sb = scPane.getHorizontalScrollBar();
sb.setValue(newX);
}
if(!tracksHeight) {
sb = scPane.getVerticalScrollBar();
sb.setValue(newY);
}
revalidate();
}
示例6: showText
import javax.swing.JScrollBar; //导入方法依赖的package包/类
void showText(String text){
logArea.append(text);
trunkTextArea(logArea);
if(autoScroll){
JScrollBar vertical = scroll.getVerticalScrollBar();
vertical.setValue(vertical.getMaximum() );
}
}
示例7: scroll
import javax.swing.JScrollBar; //导入方法依赖的package包/类
private static void scroll(JScrollBar scrollBar, MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
int unitsToScroll = e.getUnitsToScroll();
int direction = unitsToScroll < 0 ? -1 : 1;
if (unitsToScroll != 0) {
int increment = scrollBar.getUnitIncrement(direction);
int oldValue = scrollBar.getValue();
int newValue = oldValue + increment * unitsToScroll;
newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() -
scrollBar.getVisibleAmount()), scrollBar.getMinimum());
if (oldValue != newValue) scrollBar.setValue(newValue);
}
}
}
示例8: insert
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* insert the text "txt on position "pos" in the array lines
* @see java.awt.peer.TextAreaPeer
*/
@Override
public void insert(String txt, int p) {
if (jtext != null) {
boolean doScroll = (p >= jtext.getDocument().getLength() && jtext.getDocument().getLength() != 0);
jtext.insert(txt,p);
textPane.validate();
if (doScroll) {
JScrollBar bar = textPane.getVerticalScrollBar();
if (bar != null) {
bar.setValue(bar.getMaximum()-bar.getVisibleAmount());
}
}
}
}
示例9: mouseWheelMoved
import javax.swing.JScrollBar; //导入方法依赖的package包/类
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
JScrollBar scrollBar = mainScrollPane.getVerticalScrollBar();
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
int totalScrollAmount = e.getUnitsToScroll() * scrollBar.getUnitIncrement();
scrollBar.setValue(scrollBar.getValue() + totalScrollAmount);
}
}
示例10: scrollTextInfoToTop
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* Scroll the attributes pane to the top
*/
protected void scrollTextInfoToTop() {
JScrollBar verticalScrollBar = this.textInfoScroller.getVerticalScrollBar();
JScrollBar horizontalScrollBar = this.textInfoScroller.getHorizontalScrollBar();
verticalScrollBar.setValue(verticalScrollBar.getMinimum());
horizontalScrollBar.setValue(horizontalScrollBar.getMinimum());
// System.err.println("VERTICAL=" + verticalScrollBar.getValue() + ", HORIZONTAL=" + horizontalScrollBar.getValue());
}
示例11: scrollToTop
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* Scrolls scroll pane to the top left corner.
*/
public static void scrollToTop(final JScrollPane scrollPane) {
JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
verticalScrollBar.setValue(verticalScrollBar.getMinimum());
horizontalScrollBar.setValue(horizontalScrollBar.getMinimum());
}
示例12: 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;
}
示例13: doZoom
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
Zoom by factor and center on point p.
@param p point to center on.
@param factor Factor to zoom by.
*/
public void doZoom( Point2D p, double factor ) {
AffineTransform ATrans = new AffineTransform();
ATrans.scale( zoom, zoom );
Insets insets = getInsets();
Rectangle rect = getVisibleRect();
Dimension dim = getParent().getSize();
if( dim.width>rect.width) rect.width = dim.width;
if( dim.height>rect.height) rect.height = dim.height;
rect.width -= insets.left + insets.right;
rect.height -= insets.top + insets.bottom;
double nX = (p.getX() - insets.left - (rect.width/(2.*factor)));
double nY = ( p.getY() - insets.top - rect.height/(2.*factor));
Point2D newP = null;
try {
newP = ATrans.inverseTransform( new Point2D.Double(nX, nY), null );
} catch (Exception ex ) {
return;
}
ATrans.scale( factor, factor );
zoom *= factor;
newP = ATrans.transform( newP, null );
int newX = (int)newP.getX(); // + insets.left;
int newY = (int)newP.getY(); // + insets.top;
invalidate();
scrollPane.validate();
JScrollBar sb = scrollPane.getHorizontalScrollBar();
sb.setValue(newX);
sb = scrollPane.getVerticalScrollBar();
sb.setValue(newY);
revalidate();
//If this is MapApp Auto Focus
if (app instanceof MapApp) {
((MapApp) app).autoFocus();
}
}
示例14: do_pageup
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/** Performs "page up" in the JScrollPane. */
private void do_pageup() {
JScrollBar bar = getVerticalScrollBar();
bar.setValue(bar.getValue() - 200);
}
示例15: do_pagedown
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/** Performs "page down" in the JScrollPane. */
private void do_pagedown() {
JScrollBar bar = getVerticalScrollBar();
bar.setValue(bar.getValue() + 200);
}