當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。