< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 45,81 **** */ public class BasicSliderUI extends SliderUI{ // Old actions forward to an instance of this. private static final Actions SHARED_ACTION = new Actions(); public static final int POSITIVE_SCROLL = +1; public static final int NEGATIVE_SCROLL = -1; public static final int MIN_SCROLL = -2; public static final int MAX_SCROLL = +2; protected Timer scrollTimer; protected JSlider slider; protected Insets focusInsets = null; protected Insets insetCache = null; protected boolean leftToRightCache = true; protected Rectangle focusRect = null; protected Rectangle contentRect = null; protected Rectangle labelRect = null; protected Rectangle tickRect = null; protected Rectangle trackRect = null; protected Rectangle thumbRect = null; ! protected int trackBuffer = 0; // The distance that the track is from the side of the control private transient boolean isDragging; protected TrackListener trackListener; protected ChangeListener changeListener; protected ComponentListener componentListener; protected FocusListener focusListener; protected ScrollListener scrollListener; protected PropertyChangeListener propertyChangeListener; private Handler handler; private int lastValue; // Colors --- 45,103 ---- */ public class BasicSliderUI extends SliderUI{ // Old actions forward to an instance of this. private static final Actions SHARED_ACTION = new Actions(); + /** Positive scroll */ public static final int POSITIVE_SCROLL = +1; + /** Negative scroll */ public static final int NEGATIVE_SCROLL = -1; + /** Minimum scroll */ public static final int MIN_SCROLL = -2; + /** Maximum scroll */ public static final int MAX_SCROLL = +2; + /** Scroll timer */ protected Timer scrollTimer; + /** Slider */ protected JSlider slider; + /** Focus insets */ protected Insets focusInsets = null; + /** Inset cache */ protected Insets insetCache = null; + /** Left-to-right cache */ protected boolean leftToRightCache = true; + /** Focus rectangle */ protected Rectangle focusRect = null; + /** Content rectangle */ protected Rectangle contentRect = null; + /** Label rectangle */ protected Rectangle labelRect = null; + /** Tick rectangle */ protected Rectangle tickRect = null; + /** Track rectangle */ protected Rectangle trackRect = null; + /** Thumb rectangle */ protected Rectangle thumbRect = null; ! /** The distance that the track is from the side of the control */ ! protected int trackBuffer = 0; private transient boolean isDragging; + /** Track listener */ protected TrackListener trackListener; + /** Change listener */ protected ChangeListener changeListener; + /** Component listener */ protected ComponentListener componentListener; + /** Focus listener */ protected FocusListener focusListener; + /** Scroll listener */ protected ScrollListener scrollListener; + /** Property chane listener */ protected PropertyChangeListener propertyChangeListener; private Handler handler; private int lastValue; // Colors
*** 91,109 **** * Whether or not all the entries in the labeltable have the same * baseline. */ private boolean sameLabelBaselines; ! protected Color getShadowColor() { return shadowColor; } protected Color getHighlightColor() { return highlightColor; } protected Color getFocusColor() { return focusColor; } /** --- 113,142 ---- * Whether or not all the entries in the labeltable have the same * baseline. */ private boolean sameLabelBaselines; ! /** ! * Returns the shadow color. ! * @return the shadow color ! */ protected Color getShadowColor() { return shadowColor; } + /** + * Returns the highlight color. + * @return the highlight color + */ protected Color getHighlightColor() { return highlightColor; } + /** + * Returns the focus color. + * @return the focus color + */ protected Color getFocusColor() { return focusColor; } /**
*** 117,133 **** --- 150,179 ---- } ///////////////////////////////////////////////////////////////////////////// // ComponentUI Interface Implementation methods ///////////////////////////////////////////////////////////////////////////// + /** + * Creates a UI. + * @param b a component + * @return a UI + */ public static ComponentUI createUI(JComponent b) { return new BasicSliderUI((JSlider)b); } + /** + * Constructs a {@code BasicSliderUI}. + * @param b a slider + */ public BasicSliderUI(JSlider b) { } + /** + * Installs a UI. + * @param c a component + */ public void installUI(JComponent c) { slider = (JSlider) c; checkedLabelBaselines = false;
*** 160,169 **** --- 206,219 ---- lastValue = slider.getValue(); calculateGeometry(); // This figures out where the labels, ticks, track, and thumb are. } + /** + * Uninstalls a UI. + * @param c a component + */ public void uninstallUI(JComponent c) { if ( c != slider ) throw new IllegalComponentStateException( this + " was asked to deinstall() " + c + " when it only knows about "
*** 191,200 **** --- 241,254 ---- scrollListener = null; propertyChangeListener = null; slider = null; } + /** + * Installs the defaults. + * @param slider a slider + */ protected void installDefaults( JSlider slider ) { LookAndFeel.installBorder(slider, "Slider.border"); LookAndFeel.installColorsAndFont(slider, "Slider.background", "Slider.foreground", "Slider.font"); highlightColor = UIManager.getColor("Slider.highlight");
*** 206,241 **** --- 260,329 ---- // use default if missing so that BasicSliderUI can be used in other // LAFs like Nimbus if (focusInsets == null) focusInsets = new InsetsUIResource(2,2,2,2); } + /** + * Uninstalls the defaults. + * @param slider a slider + */ protected void uninstallDefaults(JSlider slider) { LookAndFeel.uninstallBorder(slider); focusInsets = null; } + /** + * Creates a track listener. + * @return a track listener + * @param slider a slider + */ protected TrackListener createTrackListener(JSlider slider) { return new TrackListener(); } + /** + * Creates a change listener. + * @return a change listener + * @param slider a slider + */ protected ChangeListener createChangeListener(JSlider slider) { return getHandler(); } + /** + * Creates a composite listener. + * @return a composite listener + * @param slider a slider + */ protected ComponentListener createComponentListener(JSlider slider) { return getHandler(); } + /** + * Creates a focus listener. + * @return a focus listener + * @param slider a slider + */ protected FocusListener createFocusListener(JSlider slider) { return getHandler(); } + /** + * Creates a scroll listener. + * @return a scroll listener + * @param slider a slider + */ protected ScrollListener createScrollListener( JSlider slider ) { return new ScrollListener(); } + /** + * Creates a property change listener. + * @return a property change listener + * @param slider a slider + */ protected PropertyChangeListener createPropertyChangeListener( JSlider slider) { return getHandler(); }
*** 244,272 **** --- 332,372 ---- handler = new Handler(); } return handler; } + /** + * Installs listeners. + * @param slider a slider + */ protected void installListeners( JSlider slider ) { slider.addMouseListener(trackListener); slider.addMouseMotionListener(trackListener); slider.addFocusListener(focusListener); slider.addComponentListener(componentListener); slider.addPropertyChangeListener( propertyChangeListener ); slider.getModel().addChangeListener(changeListener); } + /** + * Uninstalls listeners. + * @param slider a slider + */ protected void uninstallListeners( JSlider slider ) { slider.removeMouseListener(trackListener); slider.removeMouseMotionListener(trackListener); slider.removeFocusListener(focusListener); slider.removeComponentListener(componentListener); slider.removePropertyChangeListener( propertyChangeListener ); slider.getModel().removeChangeListener(changeListener); handler = null; } + /** + * Installs keyboard actions. + * @param slider a slider + */ protected void installKeyboardActions( JSlider slider ) { InputMap km = getInputMap(JComponent.WHEN_FOCUSED, slider); SwingUtilities.replaceUIInputMap(slider, JComponent.WHEN_FOCUSED, km); LazyActionMap.installLazyActionMap(slider, BasicSliderUI.class, "Slider.actionMap");
*** 300,309 **** --- 400,413 ---- map.put(new Actions(Actions.NEGATIVE_BLOCK_INCREMENT)); map.put(new Actions(Actions.MIN_SCROLL_INCREMENT)); map.put(new Actions(Actions.MAX_SCROLL_INCREMENT)); } + /** + * Uninstalls keyboard actions. + * @param slider a slider + */ protected void uninstallKeyboardActions( JSlider slider ) { SwingUtilities.replaceUIActionMap(slider, null); SwingUtilities.replaceUIInputMap(slider, JComponent.WHEN_FOCUSED, null); }
*** 428,473 **** --- 532,598 ---- } } return sameLabelBaselines; } + /** + * Returns the preferred horizontal size. + * @return the preferred horizontal size + */ public Dimension getPreferredHorizontalSize() { Dimension horizDim = (Dimension)DefaultLookup.get(slider, this, "Slider.horizontalSize"); if (horizDim == null) { horizDim = new Dimension(200, 21); } return horizDim; } + /** + * Returns the preferred vertical size. + * @return the preferred vertical size + */ public Dimension getPreferredVerticalSize() { Dimension vertDim = (Dimension)DefaultLookup.get(slider, this, "Slider.verticalSize"); if (vertDim == null) { vertDim = new Dimension(21, 200); } return vertDim; } + /** + * Returns the minimum horizontal size. + * @return the minimum horizontal size + */ public Dimension getMinimumHorizontalSize() { Dimension minHorizDim = (Dimension)DefaultLookup.get(slider, this, "Slider.minimumHorizontalSize"); if (minHorizDim == null) { minHorizDim = new Dimension(36, 21); } return minHorizDim; } + /** + * Returns the minimum vertical size. + * @return the minimum vertical size + */ public Dimension getMinimumVerticalSize() { Dimension minVertDim = (Dimension)DefaultLookup.get(slider, this, "Slider.minimumVerticalSize"); if (minVertDim == null) { minVertDim = new Dimension(21, 36); } return minVertDim; } + /** + * Returns the preferred size. + * @param c a component + * @return the preferred size + */ public Dimension getPreferredSize(JComponent c) { recalculateIfInsetsChanged(); Dimension d; if ( slider.getOrientation() == JSlider.VERTICAL ) { d = new Dimension(getPreferredVerticalSize());
*** 483,492 **** --- 608,622 ---- } return d; } + /** + * Returns the minimum size. + * @param c a component + * @return the minimum size + */ public Dimension getMinimumSize(JComponent c) { recalculateIfInsetsChanged(); Dimension d; if ( slider.getOrientation() == JSlider.VERTICAL ) {
*** 503,512 **** --- 633,647 ---- } return d; } + /** + * Returns the maximum size. + * @param c a component + * @return the maximum size + */ public Dimension getMaximumSize(JComponent c) { Dimension d = getPreferredSize(c); if ( slider.getOrientation() == JSlider.VERTICAL ) { d.height = Short.MAX_VALUE; }
*** 515,524 **** --- 650,662 ---- } return d; } + /** + * Calculates the geometry. + */ protected void calculateGeometry() { calculateFocusRect(); calculateContentRect(); calculateThumbSize(); calculateTrackBuffer();
*** 526,547 **** --- 664,694 ---- calculateTickRect(); calculateLabelRect(); calculateThumbLocation(); } + /** + * Calculates the focus rectangle. + */ protected void calculateFocusRect() { focusRect.x = insetCache.left; focusRect.y = insetCache.top; focusRect.width = slider.getWidth() - (insetCache.left + insetCache.right); focusRect.height = slider.getHeight() - (insetCache.top + insetCache.bottom); } + /** + * Calculates the thumb size rectangle. + */ protected void calculateThumbSize() { Dimension size = getThumbSize(); thumbRect.setSize( size.width, size.height ); } + /** + * Calculates the content rectangle. + */ protected void calculateContentRect() { contentRect.x = focusRect.x + focusInsets.left; contentRect.y = focusRect.y + focusInsets.top; contentRect.width = focusRect.width - (focusInsets.left + focusInsets.right); contentRect.height = focusRect.height - (focusInsets.top + focusInsets.bottom);
*** 562,571 **** --- 709,721 ---- } return result; } + /** + * Calculates the thumb location. + */ protected void calculateThumbLocation() { if ( slider.getSnapToTicks() ) { int sliderValue = slider.getValue(); int snappedValue = sliderValue; int tickSpacing = getTickSpacing();
*** 601,610 **** --- 751,763 ---- thumbRect.x = trackRect.x; thumbRect.y = valuePosition - (thumbRect.height / 2); } } + /** + * Calculates the track buffer. + */ protected void calculateTrackBuffer() { if ( slider.getPaintLabels() && slider.getLabelTable() != null ) { Component highLabel = getHighestValueLabel(); Component lowLabel = getLowestValueLabel();
*** 625,635 **** trackBuffer = thumbRect.height / 2; } } } ! protected void calculateTrackRect() { int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631) if ( slider.getOrientation() == JSlider.HORIZONTAL ) { centerSpacing = thumbRect.height; if ( slider.getPaintTicks() ) centerSpacing += getTickLength(); --- 778,790 ---- trackBuffer = thumbRect.height / 2; } } } ! /** ! * Calculates the track rectangle. ! */ protected void calculateTrackRect() { int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631) if ( slider.getOrientation() == JSlider.HORIZONTAL ) { centerSpacing = thumbRect.height; if ( slider.getPaintTicks() ) centerSpacing += getTickLength();
*** 669,678 **** --- 824,836 ---- */ protected int getTickLength() { return 8; } + /** + * Calculates the tick rectangle. + */ protected void calculateTickRect() { if ( slider.getOrientation() == JSlider.HORIZONTAL ) { tickRect.x = trackRect.x; tickRect.y = trackRect.y + trackRect.height; tickRect.width = trackRect.width;
*** 689,698 **** --- 847,859 ---- tickRect.y = trackRect.y; tickRect.height = trackRect.height; } } + /** + * Calculates the label rectangle. + */ protected void calculateLabelRect() { if ( slider.getPaintLabels() ) { if ( slider.getOrientation() == JSlider.HORIZONTAL ) { labelRect.x = tickRect.x - trackBuffer; labelRect.y = tickRect.y + tickRect.height;
*** 731,740 **** --- 892,905 ---- labelRect.height = tickRect.height; } } } + /** + * Returns the thumb size. + * @return the thumb size + */ protected Dimension getThumbSize() { Dimension size = new Dimension(); if ( slider.getOrientation() == JSlider.VERTICAL ) { size.width = 20;
*** 746,765 **** --- 911,938 ---- } return size; } + /** + * A property change handler. + */ public class PropertyChangeHandler implements PropertyChangeListener { // NOTE: This class exists only for backward compatibility. All // its functionality has been moved into Handler. If you need to add // new functionality add it to the Handler, but make sure this // class calls into the Handler. + /** {@inheritDoc} */ public void propertyChange( PropertyChangeEvent e ) { getHandler().propertyChange(e); } } + /** + * Returns the width of the widest label. + * @return the width of the widest label + */ protected int getWidthOfWidestLabel() { @SuppressWarnings("rawtypes") Dictionary dictionary = slider.getLabelTable(); int widest = 0; if ( dictionary != null ) {
*** 770,779 **** --- 943,956 ---- } } return widest; } + /** + * Returns the height of the tallest label. + * @return the height of the tallest label + */ protected int getHeightOfTallestLabel() { @SuppressWarnings("rawtypes") Dictionary dictionary = slider.getLabelTable(); int tallest = 0; if ( dictionary != null ) {
*** 784,793 **** --- 961,974 ---- } } return tallest; } + /** + * Returns the width of the highest value label. + * @return the width of the highest value label + */ protected int getWidthOfHighValueLabel() { Component label = getHighestValueLabel(); int width = 0; if ( label != null ) {
*** 795,804 **** --- 976,989 ---- } return width; } + /** + * Returns the width of the lowest value label. + * @return the width of the lowest value label + */ protected int getWidthOfLowValueLabel() { Component label = getLowestValueLabel(); int width = 0; if ( label != null ) {
*** 806,815 **** --- 991,1004 ---- } return width; } + /** + * Returns the height of the highest value label. + * @return the height of the highest value label + */ protected int getHeightOfHighValueLabel() { Component label = getHighestValueLabel(); int height = 0; if ( label != null ) {
*** 817,826 **** --- 1006,1019 ---- } return height; } + /** + * Returns the height of the lowest value label. + * @return the height of the lowest value label + */ protected int getHeightOfLowValueLabel() { Component label = getLowestValueLabel(); int height = 0; if ( label != null ) {
*** 828,837 **** --- 1021,1034 ---- } return height; } + /** + * Draws inverted. + * @return the inverted-ness + */ protected boolean drawInverted() { if (slider.getOrientation()==JSlider.HORIZONTAL) { if(BasicGraphicsUtils.isLeftToRight(slider)) { return slider.getInverted(); } else {
*** 958,990 **** --- 1155,1201 ---- if ( clip.intersects( thumbRect ) ) { paintThumb( g ); } } + /** + * Recalculates if the insets have changed. + */ protected void recalculateIfInsetsChanged() { Insets newInsets = slider.getInsets(); if ( !newInsets.equals( insetCache ) ) { insetCache = newInsets; calculateGeometry(); } } + /** + * Recalculates if the orientation has changed. + */ protected void recalculateIfOrientationChanged() { boolean ltr = BasicGraphicsUtils.isLeftToRight(slider); if ( ltr!=leftToRightCache ) { leftToRightCache = ltr; calculateGeometry(); } } + /** + * Paints focus. + * @param g the graphics + */ public void paintFocus(Graphics g) { g.setColor( getFocusColor() ); BasicGraphicsUtils.drawDashedRect( g, focusRect.x, focusRect.y, focusRect.width, focusRect.height ); } + /** + * Paints track. + * @param g the graphics + */ public void paintTrack(Graphics g) { Rectangle trackBounds = trackRect; if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
*** 1021,1030 **** --- 1232,1245 ---- g.translate(-(trackBounds.x + cx), -trackBounds.y); } } + /** + * Paints ticks. + * @param g the graphics + */ public void paintTicks(Graphics g) { Rectangle tickBounds = tickRect; g.setColor(DefaultLookup.getColor(slider, this, "Slider.tickColor", Color.black));
*** 1118,1143 **** --- 1333,1386 ---- } g.translate(-tickBounds.x, 0); } } + /** + * Paints minor tick for horizontal slider. + * @param g the graphics + * @param tickBounds the tick bounds + * @param x the x coordinate + */ protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { g.drawLine( x, 0, x, tickBounds.height / 2 - 1 ); } + /** + * Paints major tick for horizontal slider. + * @param g the graphics + * @param tickBounds the tick bounds + * @param x the x coordinate + */ protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { g.drawLine( x, 0, x, tickBounds.height - 2 ); } + /** + * Paints minor tick for vertical slider. + * @param g the graphics + * @param tickBounds the tick bounds + * @param y the y coordinate + */ protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { g.drawLine( 0, y, tickBounds.width / 2 - 1, y ); } + /** + * Paints major tick for vertical slider. + * @param g the graphics + * @param tickBounds the tick bounds + * @param y the y coordinate + */ protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { g.drawLine( 0, y, tickBounds.width - 2, y ); } + /** + * Paints the labels. + * @param g the graphics + */ public void paintLabels( Graphics g ) { Rectangle labelBounds = labelRect; @SuppressWarnings("rawtypes") Dictionary dictionary = slider.getLabelTable();
*** 1220,1229 **** --- 1463,1476 ---- g.translate( 0, labelTop ); label.paint( g ); g.translate( 0, -labelTop ); } + /** + * Paints the thumb. + * @param g the graphics + */ public void paintThumb(Graphics g) { Rectangle knobBounds = thumbRect; int w = knobBounds.width; int h = knobBounds.height;
*** 1328,1346 **** --- 1575,1602 ---- } // Used exclusively by setThumbLocation() private static Rectangle unionRect = new Rectangle(); + /** + * Sets the thumb location. + * @param x the x coordinate + * @param y the y coordinate + */ public void setThumbLocation(int x, int y) { unionRect.setBounds( thumbRect ); thumbRect.setLocation( x, y ); SwingUtilities.computeUnion( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height, unionRect ); slider.repaint( unionRect.x, unionRect.y, unionRect.width, unionRect.height ); } + /** + * Scrolls by block. + * @param direction the direction + */ public void scrollByBlock(int direction) { synchronized(slider) { int blockIncrement = (slider.getMaximum() - slider.getMinimum()) / 10; if (blockIncrement == 0) {
*** 1358,1367 **** --- 1614,1627 ---- int delta = blockIncrement * ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL); slider.setValue(slider.getValue() + delta); } } + /** + * Scrolls by unit. + * @param direction the direction + */ public void scrollByUnit(int direction) { synchronized(slider) { int delta = ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL); if (slider.getSnapToTicks()) {
*** 1382,1391 **** --- 1642,1656 ---- */ protected void scrollDueToClickInTrack( int dir ) { scrollByBlock( dir ); } + /** + * Returns the x position for a value. + * @param value the value + * @return the x position for a value + */ protected int xPositionForValue( int value ) { int min = slider.getMinimum(); int max = slider.getMaximum(); int trackLength = trackRect.width; double valueRange = (double)max - (double)min;
*** 1407,1416 **** --- 1672,1686 ---- xPosition = Math.min( trackRight, xPosition ); return xPosition; } + /** + * Returns the y position for a value. + * @param value the value + * @return the y position for a value + */ protected int yPositionForValue( int value ) { return yPositionForValue(value, trackRect.y, trackRect.height); } /**
*** 1603,1615 **** * * This class should be treated as a &quot;protected&quot; inner class. * Instantiate it only within subclasses of <code>Foo</code>. */ public class TrackListener extends MouseInputAdapter { protected transient int offset; ! protected transient int currentMouseX, currentMouseY; public void mouseReleased(MouseEvent e) { if (!slider.isEnabled()) { return; } --- 1873,1892 ---- * * This class should be treated as a &quot;protected&quot; inner class. * Instantiate it only within subclasses of <code>Foo</code>. */ public class TrackListener extends MouseInputAdapter { + /** The offset */ protected transient int offset; ! /** Current mouse x. */ ! protected transient int currentMouseX; ! /** Current mouse y. */ ! protected transient int currentMouseY; + /** + * {@inheritDoc} + */ public void mouseReleased(MouseEvent e) { if (!slider.isEnabled()) { return; }
*** 1734,1743 **** --- 2011,2025 ---- scrollListener.setDirection(direction); scrollTimer.start(); } } + /** + * Returns if scrolling should occur + * @param direction the direction. + * @return if scrolling should occur + */ public boolean shouldScroll(int direction) { Rectangle r = thumbRect; if (slider.getOrientation() == JSlider.VERTICAL) { if (drawInverted() ? direction < 0 : direction > 0) { if (r.y <= currentMouseY) {
*** 1837,1846 **** --- 2119,2129 ---- slider.setValue(valueForXPosition(thumbMiddle)); break; } } + /** {@inheritDoc} */ public void mouseMoved(MouseEvent e) { } } /** * Scroll-event listener.
*** 1853,1880 **** --- 2136,2180 ---- // bug in InternetExplorer browser. It was protected. Work around // for 4109432 int direction = POSITIVE_SCROLL; boolean useBlockIncrement; + /** + * Constructs a {@code ScrollListener} + */ public ScrollListener() { direction = POSITIVE_SCROLL; useBlockIncrement = true; } + /** + * Constructs a {@code ScrollListener} + * @param dir the direction + * @param block whether or not to scroll by block + */ public ScrollListener(int dir, boolean block) { direction = dir; useBlockIncrement = block; } + /** + * Sets the direction. + * @param direction the new direction + */ public void setDirection(int direction) { this.direction = direction; } + /** + * Sets scrolling by block + * @param block the new scroll by block value + */ public void setScrollByBlock(boolean block) { this.useBlockIncrement = block; } + /** {@inheritDoc} */ public void actionPerformed(ActionEvent e) { if (useBlockIncrement) { scrollByBlock(direction); } else {
*** 1943,1962 **** --- 2243,2270 ---- // class calls into the Actions. int dir; boolean block; JSlider slider; + /** + * Constructs an {@code ActionScroller}. + * @param slider a slider + * @param dir the direction + * @param block block scrolling or not + */ public ActionScroller( JSlider slider, int dir, boolean block) { this.dir = dir; this.block = block; this.slider = slider; } + /** {@inheritDoc} */ public void actionPerformed(ActionEvent e) { SHARED_ACTION.scroll(slider, BasicSliderUI.this, dir, block); } + /** {@inheritDoc} */ public boolean isEnabled() { boolean b = true; if (slider != null) { b = slider.isEnabled(); }
< prev index next >