当前位置: 首页>>代码示例>>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;未经允许,请勿转载。