当前位置: 首页>>代码示例>>Java>>正文


Java JScrollBar.setValue方法代码示例

本文整理汇总了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()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:KeywordsPanel.java

示例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();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:18,代码来源:SCSImage.java

示例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());
    }
}
 
开发者ID:pascalgn,项目名称:jiracli,代码行数:23,代码来源:ConsoleTextArea.java

示例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();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:26,代码来源:XMap.java

示例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();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:25,代码来源:XYGraph.java

示例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() );
	}
}
 
开发者ID:jonasxiao,项目名称:FinalSpeed,代码行数:9,代码来源:LogFrame.java

示例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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ChartPanel.java

示例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());
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:XTextAreaPeer.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DebuggingViewComponent.java

示例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());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:11,代码来源:CatalogViewer.java

示例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());
}
 
开发者ID:igr,项目名称:swingspy,代码行数:10,代码来源:SwingUtil.java

示例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;
}
 
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:33,代码来源:SerialMonitorDisplayPane.java

示例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();
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:42,代码来源:XMap.java

示例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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:6,代码来源:OurConsole.java

示例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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:6,代码来源:OurConsole.java


注:本文中的javax.swing.JScrollBar.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。