Java Code Examples for javax.swing.JScrollBar#VERTICAL
The following examples show how to use
javax.swing.JScrollBar#VERTICAL .
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: PScrollBarUI.java From PolyGlot with MIT License | 6 votes |
@Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { Graphics2D antiAlias = (Graphics2D) g; antiAlias.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.translate(trackBounds.x, trackBounds.y); if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { g.setColor(darkShadow); g.fillRect(0, 0, trackBounds.width, trackBounds.height); g.setColor(shadow); g.fillRect(1, 1, trackBounds.width - 2, trackBounds.height - 2); } else { g.setColor(darkShadow); g.fillRect(0, 0, trackBounds.width, trackBounds.height); g.setColor(shadow); g.fillRect(1, 1, trackBounds.width - 2, trackBounds.height - 2); } g.translate( -trackBounds.x, -trackBounds.y ); }
Example 2
Source File: MetalScrollBarUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public Dimension getPreferredSize( JComponent c ) { if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { return new Dimension( scrollBarWidth, scrollBarWidth * 3 + 10 ); } else // Horizontal { return new Dimension( scrollBarWidth * 3 + 10, scrollBarWidth ); } }
Example 3
Source File: MotifScrollBarUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public Dimension getPreferredSize(JComponent c) { Insets insets = c.getInsets(); int dx = insets.left + insets.right; int dy = insets.top + insets.bottom; return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(dx + 11, dy + 33) : new Dimension(dx + 33, dy + 11); }
Example 4
Source File: MotifScrollBarUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public Dimension getPreferredSize(JComponent c) { Insets insets = c.getInsets(); int dx = insets.left + insets.right; int dy = insets.top + insets.bottom; return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(dx + 11, dy + 33) : new Dimension(dx + 33, dy + 11); }
Example 5
Source File: MetalScrollBarUI.java From hottub with GNU General Public License v2.0 | 5 votes |
public Dimension getPreferredSize( JComponent c ) { if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { return new Dimension( scrollBarWidth, scrollBarWidth * 3 + 10 ); } else // Horizontal { return new Dimension( scrollBarWidth * 3 + 10, scrollBarWidth ); } }
Example 6
Source File: MotifScrollBarUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public Dimension getPreferredSize(JComponent c) { Insets insets = c.getInsets(); int dx = insets.left + insets.right; int dy = insets.top + insets.bottom; return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(dx + 11, dy + 33) : new Dimension(dx + 33, dy + 11); }
Example 7
Source File: MetalScrollBarUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public Dimension getPreferredSize( JComponent c ) { if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { return new Dimension( scrollBarWidth, scrollBarWidth * 3 + 10 ); } else // Horizontal { return new Dimension( scrollBarWidth * 3 + 10, scrollBarWidth ); } }
Example 8
Source File: WindowsOutlookBarUI.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public Dimension getPreferredSize(JComponent c) { return (scrollbar.getOrientation() == JScrollBar.VERTICAL)?new Dimension(8, 48):new Dimension(48, 8); }
Example 9
Source File: MetalScrollBarUI.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 10
Source File: MetalScrollBarUI.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 11
Source File: DetailsPanel.java From visualvm with GNU General Public License v2.0 | 4 votes |
private void initComponents() { table = new DetailsTable(); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JViewport viewport = new Viewport(table); final JScrollPane tableScroll = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setViewport(viewport); tableScroll.setBorder(BorderFactory.createEmptyBorder()); tableScroll.setViewportBorder(BorderFactory.createEmptyBorder()); tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel()); scrollBar = new ScrollBar(JScrollBar.VERTICAL) { public int getUnitIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableUnitIncrement(vr, getOrientation(), direction); } public int getBlockIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableBlockIncrement(vr, getOrientation(), direction); } public void setValues(int newValue, int newExtent, int newMin, int newMax) { setEnabled(newExtent < newMax); if (isEnabled() && !isSelectionChanging() && isTrackingEnd()) newValue = newMax - newExtent; super.setValues(newValue, newExtent, newMin, newMax); } }; tableScroll.setVerticalScrollBar(scrollBar); dataContainer = tableScroll; JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER); noDataLabel.setEnabled(false); noDataContainer = new JPanel(new BorderLayout()); noDataContainer.setOpaque(false); noDataContainer.add(noDataLabel, BorderLayout.CENTER); setOpaque(false); setLayout(new BorderLayout()); add(noDataContainer, BorderLayout.CENTER); }
Example 12
Source File: SeaGlassScrollBarUI.java From seaglass with Apache License 2.0 | 4 votes |
protected JButton createDecreaseButton(int orientation) { SeaGlassArrowButton synthArrowButton = new SeaGlassArrowButton(orientation) { @Override public boolean contains(int x, int y) { // if there is an overlap between the track and button if (decrGap < 0) { // FIXME Need to take RtL orientation into account. if (buttonsTogether.isInState(scrollbar)) { int minX = 0; int minY = 0; if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { // adjust the height by decrGap // Note: decrGap is negative! minY -= decrGap; } else { // adjust the width by decrGap // Note: decrGap is negative! minX -= decrGap; } return (x >= minX) && (x < getWidth()) && (y >= minY) && (y < getHeight()); } else { int width = getWidth(); int height = getHeight(); if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { // adjust the height by decrGap // Note: decrGap is negative! height += decrGap; } else { // adjust the width by decrGap // Note: decrGap is negative! width += decrGap; } return (x >= 0) && (x < width) && (y >= 0) && (y < height); } } return super.contains(x, y); } }; synthArrowButton.setName("ScrollBar.button"); return synthArrowButton; }
Example 13
Source File: XTextAreaPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override public JScrollBar createVerticalScrollBar() { return new XAWTScrollBar(JScrollBar.VERTICAL); }
Example 14
Source File: MetalScrollBarUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 15
Source File: XTextAreaPeer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public JScrollBar createVerticalScrollBar() { return new XAWTScrollBar(JScrollBar.VERTICAL); }
Example 16
Source File: MetalScrollBarUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 17
Source File: DetailsPanel.java From netbeans with Apache License 2.0 | 4 votes |
private void initComponents() { table = new DetailsTable(); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JViewport viewport = new Viewport(table); final JScrollPane tableScroll = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setViewport(viewport); tableScroll.setBorder(BorderFactory.createEmptyBorder()); tableScroll.setViewportBorder(BorderFactory.createEmptyBorder()); tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel()); scrollBar = new ScrollBar(JScrollBar.VERTICAL) { public int getUnitIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableUnitIncrement(vr, getOrientation(), direction); } public int getBlockIncrement(int direction) { JViewport vp = tableScroll.getViewport(); Scrollable view = (Scrollable)(vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableBlockIncrement(vr, getOrientation(), direction); } public void setValues(int newValue, int newExtent, int newMin, int newMax) { setEnabled(newExtent < newMax); if (isEnabled() && !isSelectionChanging() && isTrackingEnd()) newValue = newMax - newExtent; super.setValues(newValue, newExtent, newMin, newMax); } }; tableScroll.setVerticalScrollBar(scrollBar); dataContainer = tableScroll; JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER); noDataLabel.setEnabled(false); noDataContainer = new JPanel(new BorderLayout()); noDataContainer.setOpaque(false); noDataContainer.add(noDataLabel, BorderLayout.CENTER); setOpaque(false); setLayout(new BorderLayout()); add(noDataContainer, BorderLayout.CENTER); }
Example 18
Source File: XTextAreaPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public JScrollBar createVerticalScrollBar() { return new XAWTScrollBar(JScrollBar.VERTICAL); }
Example 19
Source File: MetalScrollBarUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 20
Source File: MetalScrollBarUI.java From Java8CN with Apache License 2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }