/** * Creates a new JScrollBar object with the given orientation, value, min, max, and extent. * * @param orientation The orientation to use. * @param value The value to use. * @param extent The extent to use. * @param min The minimum value of the scrollbar. * @param max The maximum value of the scrollbar. */ public JScrollBar(int orientation, int value, int extent, int min, int max) { model = new DefaultBoundedRangeModel(value, extent, min, max); if (orientation != SwingConstants.HORIZONTAL && orientation != SwingConstants.VERTICAL) throw new IllegalArgumentException(orientation + " is not a legal orientation"); this.orientation = orientation; updateUI(); }
/** * Creates a scrollbar with the specified orientation, value, extent, minimum, and maximum. The * "extent" is the size of the viewable area. It is also known as the "visible amount". * * <p>Note: Use <code>setBlockIncrement</code> to set the block increment to a size slightly * smaller than the view's extent. That way, when the user jumps the knob to an adjacent position, * one or two lines of the original contents remain in view. * * @exception IllegalArgumentException if orientation is not one of VERTICAL, HORIZONTAL * @see #setOrientation * @see #setValue * @see #setVisibleAmount * @see #setMinimum * @see #setMaximum */ public JScrollBar(int orientation, int value, int extent, int min, int max) { checkOrientation(orientation); this.unitIncrement = 1; this.blockIncrement = (extent == 0) ? 1 : extent; this.orientation = orientation; this.model = new DefaultBoundedRangeModel(value, extent, min, max); this.model.addChangeListener(fwdAdjustmentEvents); setRequestFocusEnabled(false); updateUI(); }