當前位置: 首頁>>代碼示例>>Java>>正文


Java JScrollBar類代碼示例

本文整理匯總了Java中javax.swing.JScrollBar的典型用法代碼示例。如果您正苦於以下問題:Java JScrollBar類的具體用法?Java JScrollBar怎麽用?Java JScrollBar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JScrollBar類屬於javax.swing包,在下文中一共展示了JScrollBar類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import javax.swing.JScrollBar; //導入依賴的package包/類
public void run() {
    if (this.bar == null) {
        this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
        this.bar.setPreferredSize(new Dimension(400, 20));

        JFrame frame = new JFrame();
        frame.add(this.bar);
        frame.pack();
        frame.setVisible(true);
    }
    else if (40 != this.bar.getValue()) {
        System.out.println("name = " + UIManager.getLookAndFeel().getName());
        System.out.println("value = " + this.bar.getValue());
    }
    else {
        SwingUtilities.getWindowAncestor(this.bar).dispose();
        this.bar = null;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:Test7163696.java

示例2: 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

示例3: updateHorizontalScrollBars

import javax.swing.JScrollBar; //導入依賴的package包/類
private void updateHorizontalScrollBars(ProfilerTable table, int column, boolean layout) {
    if (column != -1) {
        JScrollBar scroll = getScroller(column);
        int offset = table.getColumnOffset(column);
        int columnPref = table.getColumnPreferredWidth(column);
        int _column = table.convertColumnIndexToView(column);
        int columnAct = table.getTableHeader().getHeaderRect(_column).width;
        if (columnPref > columnAct) {
            int value = Math.min(offset, columnPref - columnAct);
            scroll.setValues(value, columnAct, 0, columnPref);
        } else {
            scroll.setValues(0, 0, 0, 0);
        }
    }
    
    if (layout) {
        doLayout();
        scrollersPanel.doLayout();
        repaint();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:ProfilerTableContainer.java

示例4: 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;
zoomX = zoomY = zoom;
		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,代碼行數:19,代碼來源:SCSImage2.java

示例5: reset

import javax.swing.JScrollBar; //導入依賴的package包/類
public static void reset() {
    entries.clear();
    add(Component.class, RUnknownComponent.class);
    add(Window.class, RWindow.class);
    add(JTable.class, RTable.class);
    add(JTableHeader.class, RTableHeader.class);
    add(AbstractButton.class, RAbstractButton.class);
    add(JToggleButton.class, RToggleButton.class);
    add(JComboBox.class, RComboBox.class);
    add(JTextComponent.class, RTextComponent.class);
    add(JTree.class, RTree.class);
    add(JList.class, RList.class);
    add(JTabbedPane.class, RTabbedPane.class);
    add(JMenuItem.class, RMenuItem.class);
    add(JSlider.class, RSlider.class);
    add(JProgressBar.class, RProgressBar.class);
    add(JSpinner.class, RSpinner.class);
    add(DefaultEditor.class, RDefaultEditor.class);
    add(JColorChooser.class, RColorChooser.class);
    add(JSplitPane.class, RSplitPane.class);
    add(BasicSplitPaneDivider.class, RSplitPane.class);
    add(JFileChooser.class, RFileChooser.class);
    add(JEditorPane.class, REditorPane.class);
    add(JLabel.class, RLabel.class);
    add(JScrollBar.class, RIgnoreComponent.class);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:27,代碼來源:RComponentFactory.java

示例6: print

import javax.swing.JScrollBar; //導入依賴的package包/類
public void print(String string) {
	System.out.print(string);


	Document document = this.textArea.getDocument();
	final JScrollBar scrollBar = this.scrollPane.getVerticalScrollBar();

	boolean shouldScroll = (scrollBar.getValue() + scrollBar.getSize().getHeight() +
			MONOSPACED.getSize() * 2 > scrollBar.getMaximum());
	try {
		document.insertString(document.getLength(), string, null);
	} catch (BadLocationException ignored) {

	}

	if (shouldScroll) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				scrollBar.setValue(2147483647);
			}
		});
	}
}
 
開發者ID:DivergenceBot,項目名稱:Bootstrapper,代碼行數:24,代碼來源:Bootstrapper.java

示例7: 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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:LWScrollBarPeer.java

示例8: getMinimumSize

import javax.swing.JScrollBar; //導入依賴的package包/類
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:LWTextAreaPeer.java

示例9: insert

import javax.swing.JScrollBar; //導入依賴的package包/類
@Override
public void insert(final String text, final int pos) {
    final ScrollableJTextArea pane = getDelegate();
    synchronized (getDelegateLock()) {
        final JTextArea area = pane.getView();
        final boolean doScroll = pos >= area.getDocument().getLength()
                                 && area.getDocument().getLength() != 0;
        area.insert(text, pos);
        revalidate();
        if (doScroll) {
            final JScrollBar vbar = pane.getVerticalScrollBar();
            if (vbar != null) {
                vbar.setValue(vbar.getMaximum() - vbar.getVisibleAmount());
            }
        }
    }
    repaintPeer();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:LWTextAreaPeer.java

示例10: uninstallDefaults

import javax.swing.JScrollBar; //導入依賴的package包/類
@Override
protected void uninstallDefaults(JScrollPane c) {
    super.uninstallDefaults(c);

    JScrollBar vsb = scrollpane.getVerticalScrollBar();
    if (vsb != null) {
        if (vsb.getBorder() == vsbBorder) {
            vsb.setBorder(null);
        }
        vsbBorder = null;
    }

    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
    if (hsb != null) {
        if (hsb.getBorder() == hsbBorder) {
            hsb.setBorder(null);
        }
        hsbBorder = null;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:XTextAreaPeer.java

示例11: setPointerIfPointOverScrollbar

import javax.swing.JScrollBar; //導入依賴的package包/類
private boolean setPointerIfPointOverScrollbar( JScrollBar bar, Point point ) {
    if ( ! bar.getBounds().contains( point ) ) {
        return false;
    }
    current.setBar( bar );
    Point local = toLocalSpace( bar, point );

    XTextAreaPeer.XAWTScrollBarUI ui =
        (XTextAreaPeer.XAWTScrollBarUI) bar.getUI();

    if ( ! setPointerIfPointOverButton( ui.getIncreaseButton(), local ) ) {
        setPointerIfPointOverButton( ui.getDecreaseButton(), local );
    }

    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:XTextAreaPeer.java

示例12: maintainScrollBar

import javax.swing.JScrollBar; //導入依賴的package包/類
/**
 *
 */
protected void maintainScrollBar(boolean horizontal, double factor,
		boolean center)
{
	JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar()
			: getVerticalScrollBar();

	if (scrollBar != null)
	{
		BoundedRangeModel model = scrollBar.getModel();
		int newValue = (int) Math.round(model.getValue() * factor)
				+ (int) Math.round((center) ? (model.getExtent()
						* (factor - 1) / 2) : 0);
		model.setValue(newValue);
	}
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:19,代碼來源:mxGraphComponent.java

示例13: scrollTo

import javax.swing.JScrollBar; //導入依賴的package包/類
public void scrollTo (int t) {
	if(cruise==null) return;
	int i=0;
	int x=0;
	while( i<cruise.start.length && cruise.start[i]<t ) i++;
	if( i==cruise.start.length ) {
		x = width;
	} else if( t<cruise.start[i] ) {
		x = cruise.xPosition[i];
	} else if( t>cruise.start[i]+30*cruise.panelSize[i][0] ) {
		x = cruise.xPosition[i] + cruise.panelSize[i][0];
	} else {
		x = cruise.xPosition[i] + (t-cruise.start[i])/30;
	}
	Rectangle r = getVisibleRect();
	x = (int) (x*zoomX) - r.width/2;
	JScrollBar sb = scrollPane.getHorizontalScrollBar();
	sb.setValue(x);
	repaint();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:21,代碼來源:SCSImage2.java

示例14: init

import javax.swing.JScrollBar; //導入依賴的package包/類
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:Test8039464.java

示例15: getScrollDirection

import javax.swing.JScrollBar; //導入依賴的package包/類
@Override
public int getScrollDirection(JScrollBarOperator oper) {
    Point toPoint = SwingUtilities.
            convertPoint(comp, x, y, getViewport().getView());
    int to = (orientation == JScrollBar.HORIZONTAL) ? toPoint.x : toPoint.y;
    int ln = (orientation == JScrollBar.HORIZONTAL) ? width : height;
    int lv = (orientation == JScrollBar.HORIZONTAL) ? getViewport().getWidth() : getViewport().getHeight();
    int vl = oper.getValue();
    if (to < vl) {
        return ScrollAdjuster.DECREASE_SCROLL_DIRECTION;
    } else if ((to + ln - 1) > (vl + lv)
            && to > vl) {
        return ScrollAdjuster.INCREASE_SCROLL_DIRECTION;
    } else {
        return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:JScrollPaneOperator.java


注:本文中的javax.swing.JScrollBar類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。