Java Code Examples for javax.swing.JScrollBar#HORIZONTAL

The following examples show how to use javax.swing.JScrollBar#HORIZONTAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Test7163696.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 2
Source File: Test7163696.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 3
Source File: Test7163696.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 4
Source File: BEScrollBarUI.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public Dimension getPreferredSize() 
{
	int size = 16;
	if (scrollbar != null) 
	{
		switch (scrollbar.getOrientation()) 
		{
			case JScrollBar.VERTICAL:
				size = scrollbar.getWidth();
				break;
			case JScrollBar.HORIZONTAL:
				size = scrollbar.getHeight();
				break;
		}
		size = Math.max(size, 5);
	}
	return new Dimension(size, size);
}
 
Example 5
Source File: JScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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;
    }
}
 
Example 6
Source File: Test7163696.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 7
Source File: Test7163696.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 8
Source File: Test7163696.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 9
Source File: SimpleXYChart.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void enableZooming() {
    scroller = new JScrollBar(JScrollBar.HORIZONTAL);
    attachHorizontalScrollBar(scroller);
    
    zoomInAction = new ZoomInAction();
    zoomOutAction = new ZoomOutAction();
    toggleViewAction = new ToggleViewAction();
    
    listener = new VisibleBoundsListener();
    addConfigurationListener(listener);
}
 
Example 10
Source File: Palette.java    From nanoleaf-desktop with MIT License 5 votes vote down vote up
private void initUI()
{
	setLayout(new MigLayout("", "[]", "[]"));
	add(Box.createRigidArea(new Dimension(width, height)), "cell 0 0,alignx left,aligny top");
	setBackground(Color.DARK_GRAY);
	palette = new ArrayList<Color>();
	palette.add(new Color(255, 0, 0));
	palette.add(new Color(0, 255, 0));
	palette.add(new Color(0, 0, 255));
	
	scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
	scrollBar.setUI(new ModernScrollBarUI());
	scrollBar.setPreferredSize(new Dimension(width, 20));
	scrollBar.setMaximum(11);
	scrollBar.setMinimum(0);
	scrollBar.setValue(0);
	scrollBar.setVisible(false);
	scrollBar.addAdjustmentListener(new AdjustmentListener()
	{
		@Override
		public void adjustmentValueChanged(AdjustmentEvent e)
		{
			repaint();
		}
	});
	add(scrollBar, "cell 0 1");
	
	addMouseListener(new MouseHandler());
}
 
Example 11
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JScrollBar createFakeHSB(final JScrollBar hsb) {
    return new JScrollBar(JScrollBar.HORIZONTAL) {

        @Override
        public Dimension getPreferredSize() {
            Dimension dim = hsb.getPreferredSize();
            return new Dimension(dim.width, 2*dim.height);
        }

    };
}
 
Example 12
Source File: XTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JScrollBar createHorizontalScrollBar() {
    return new XAWTScrollBar(JScrollBar.HORIZONTAL);
}
 
Example 13
Source File: DrawingViewScrollPane.java    From openAGV with Apache License 2.0 4 votes vote down vote up
public PlacardScrollbar() {
  super(JScrollBar.HORIZONTAL);
  setPreferredSize(new Dimension(100, 18));
}
 
Example 14
Source File: XTextAreaPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JScrollBar createHorizontalScrollBar() {
    return new XAWTScrollBar(JScrollBar.HORIZONTAL);
}
 
Example 15
Source File: XTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JScrollBar createHorizontalScrollBar() {
    return new XAWTScrollBar(JScrollBar.HORIZONTAL);
}
 
Example 16
Source File: LuckScrollBarUI.java    From littleluck with Apache License 2.0 4 votes vote down vote up
/**
 * <p>使用点九图绘制滑块。</p>
 *
 * <p>use nine patch image to draw the thumb.</p>
 */
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
{
    if (thumbBounds.isEmpty() || !scrollbar.isEnabled())
    {
        return;
    }

    int w = thumbBounds.width;
    int h = thumbBounds.height;

    g.translate(thumbBounds.x, thumbBounds.y);

    // 为了美观,这里和内容面板保持一个像素的间距。
    // For aesthetic reasons, this and the content panel maintain a pixel pitch.
    if(scrollbar.getOrientation() == JScrollBar.VERTICAL)
    {
        w = w - 1;
    }
    else if(scrollbar.getOrientation() == JScrollBar.HORIZONTAL)
    {
        h = h - 1;
    }
    
    // 增加hover效果
    Graphics2D g2d = (Graphics2D)g;
    
    AlphaComposite composite = (AlphaComposite) g2d.getComposite();
    
    if(!isThumbRollover())
    {
        AlphaComposite transulent = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.7f);
        
        g2d.setComposite(transulent);
    }

    if (np != null)
    {
        np.drawNinePatch(g2d, 0, 0, w, h);
    }

    g.translate(-thumbBounds.x, -thumbBounds.y);
    
    g2d.setComposite(composite);
}
 
Example 17
Source File: XTextAreaPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JScrollBar createHorizontalScrollBar() {
    return new XAWTScrollBar(JScrollBar.HORIZONTAL);
}
 
Example 18
Source File: GanttChart.java    From swift-k with Apache License 2.0 4 votes vote down vote up
public GanttChart(SystemState state) {
    this.state = state;
	scale = INITIAL_SCALE;
	jobs = new ArrayList<Job>();
	jobmap = new HashMap<String, Job>();

	header = new JTable() {
		public Dimension getPreferredSize() {
			Dimension d = super.getPreferredSize();
			return new Dimension(50, d.height);
		}
	};
	header.setModel(hmodel = new HeaderModel());
	header.setShowHorizontalLines(true);
	header.setPreferredScrollableViewportSize(new Dimension(100, 10));
	header.setDefaultRenderer(Job.class, new JobNameRenderer());

	table = new JTable();
	table.setDoubleBuffered(true);
	table.setModel(cmodel = new ChartModel());
	table.setShowHorizontalLines(true);
	table.setDefaultRenderer(Job.class, new JobRenderer());
	JPanel jp = new JPanel();
	jp.setLayout(new BorderLayout());
	jp.add(table, BorderLayout.CENTER);

	csp = new JScrollPane(jp);
	csp.setColumnHeaderView(new Tickmarks());
	csp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	csp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	csp.setRowHeaderView(header);
	csp.getVerticalScrollBar().getModel().addChangeListener(this);
	
	hsb = new JScrollBar(JScrollBar.HORIZONTAL);
	hsb.setVisible(true);
	hsb.getModel().addChangeListener(this);

	setLayout(new BorderLayout());
	add(csp, BorderLayout.CENTER);
	add(createTools(), BorderLayout.NORTH);
	add(hsb, BorderLayout.SOUTH);
	
	state.schedule(new TimerTask() {
           @Override
           public void run() {
               GanttChart.this.actionPerformed(null);
           }
	}, 1000, 1000);
}
 
Example 19
Source File: XTextAreaPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JScrollBar createHorizontalScrollBar() {
    return new XAWTScrollBar(JScrollBar.HORIZONTAL);
}
 
Example 20
Source File: XTextAreaPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JScrollBar createHorizontalScrollBar() {
    return new XAWTScrollBar(JScrollBar.HORIZONTAL);
}