1. /*
  2. * @(#)JScrollBar.java 1.61 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing;
  8. import java.io.Serializable;
  9. import java.awt.Component;
  10. import java.awt.Adjustable;
  11. import java.awt.Dimension;
  12. import java.awt.event.AdjustmentListener;
  13. import java.awt.event.AdjustmentEvent;
  14. import java.awt.Graphics;
  15. import javax.swing.event.*;
  16. import javax.swing.plaf.*;
  17. import javax.accessibility.*;
  18. import java.io.ObjectOutputStream;
  19. import java.io.ObjectInputStream;
  20. import java.io.IOException;
  21. /**
  22. * An implementation of a scrollbar. The user positions the knob in the
  23. * scrollbar to determine the contents of the viewing area. The
  24. * program typically adjusts the display so that the end of the
  25. * scrollbar represents the end of the displayable contents, or 100%
  26. * of the contents. The start of the scrollbar is the beginning of the
  27. * displayable contents, or 0%. The postion of the knob within
  28. * those bounds then translates to the corresponding percentage of
  29. * the displayable contents.
  30. * <p>
  31. * Typically, as the position of the knob in the scrollbar changes
  32. * a corresponding change is made to the position of the JViewport on
  33. * the underlying view, changing the contents of the JViewport.
  34. * <p>
  35. * <strong>Warning:</strong>
  36. * Serialized objects of this class will not be compatible with
  37. * future Swing releases. The current serialization support is appropriate
  38. * for short term storage or RMI between applications running the same
  39. * version of Swing. A future release of Swing will provide support for
  40. * long term persistence.
  41. *
  42. * @see JScrollPane
  43. * @beaninfo
  44. * attribute: isContainer false
  45. * description: A component that helps determine the visible content range of an area.
  46. *
  47. * @version 1.61 11/29/01
  48. * @author David Kloba
  49. */
  50. public class JScrollBar extends JComponent implements Adjustable, Accessible
  51. {
  52. /**
  53. * @see #getUIClassID
  54. * @see #readObject
  55. */
  56. private static final String uiClassID = "ScrollBarUI";
  57. /**
  58. * All changes from the model are treated as though the user moved
  59. * the scrollbar knob.
  60. */
  61. private ChangeListener fwdAdjustmentEvents = new ModelListener();
  62. /**
  63. * The model that represents the scrollbar's minimum, maximum, extent
  64. * (aka "visibleAmount") and current value.
  65. * @see #setModel
  66. */
  67. protected BoundedRangeModel model;
  68. /**
  69. * @see #setOrientation
  70. */
  71. protected int orientation;
  72. /**
  73. * @see #setUnitIncrement
  74. */
  75. protected int unitIncrement;
  76. /**
  77. * @see #setBlockIncrement
  78. */
  79. protected int blockIncrement;
  80. private void checkOrientation(int orientation) {
  81. switch (orientation) {
  82. case VERTICAL:
  83. case HORIZONTAL:
  84. break;
  85. default:
  86. throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL");
  87. }
  88. }
  89. /**
  90. * Creates a scrollbar with the specified orientation,
  91. * value, extent, mimimum, and maximum.
  92. * The "extent" is the size of the viewable area. It is also known
  93. * as the "visible amount".
  94. * <p>
  95. * Note: Use <code>setBlockIncrement</code> to set the block
  96. * increment to a size slightly smaller than the view's extent.
  97. * That way, when the user jumps the knob to an adjacent position,
  98. * one or two lines of the original contents remain in view.
  99. *
  100. * @exception IllegalArgumentException if orientation is not one of VERTICAL, HORIZONTAL
  101. *
  102. * @see #setOrientation
  103. * @see #setValue
  104. * @see #setVisibleAmount
  105. * @see #setMinimum
  106. * @see #setMaximum
  107. */
  108. public JScrollBar(int orientation, int value, int extent, int min, int max)
  109. {
  110. checkOrientation(orientation);
  111. this.unitIncrement = 1;
  112. this.blockIncrement = (extent == 0) ? 1 : extent;
  113. this.orientation = orientation;
  114. this.model = new DefaultBoundedRangeModel(value, extent, min, max);
  115. this.model.addChangeListener(fwdAdjustmentEvents);
  116. updateUI();
  117. }
  118. /**
  119. * Creates a scrollbar with the specified orientation
  120. * and the following initial values:
  121. * <pre>
  122. * minimum = 0
  123. * maximum = 100
  124. * value = 0
  125. * extent = 10
  126. * </pre>
  127. */
  128. public JScrollBar(int orientation) {
  129. this(orientation, 0, 10, 0, 100);
  130. }
  131. /**
  132. * Creates a vertical scrollbar with the following initial values:
  133. * <pre>
  134. * minimum = 0
  135. * maximum = 100
  136. * value = 0
  137. * extent = 10
  138. * </pre>
  139. */
  140. public JScrollBar() {
  141. this(VERTICAL);
  142. }
  143. /**
  144. * Returns the delegate that implements the look and feel for
  145. * this component.
  146. *
  147. * @see JComponent#setUI
  148. */
  149. public ScrollBarUI getUI() {
  150. return (ScrollBarUI)ui;
  151. }
  152. /**
  153. * Overrides <code>JComponent.updateUI</code>.
  154. * @see JComponent#updateUI
  155. */
  156. public void updateUI() {
  157. setUI((ScrollBarUI)UIManager.getUI(this));
  158. }
  159. /**
  160. * Returns the name of the LookAndFeel class for this component.
  161. *
  162. * @return "ScrollBarUI"
  163. * @see JComponent#getUIClassID
  164. * @see UIDefaults#getUI
  165. */
  166. public String getUIClassID() {
  167. return uiClassID;
  168. }
  169. /**
  170. * Returns the component's orientation (horizontal or vertical).
  171. *
  172. * @return VERTICAL or HORIZONTAL
  173. * @see #setOrientation
  174. * @see java.awt.Adjustable#getOrientation
  175. */
  176. public int getOrientation() {
  177. return orientation;
  178. }
  179. /**
  180. * Set the scrollbar's orientation to either VERTICAL or
  181. * HORIZONTAL.
  182. *
  183. * @exception IllegalArgumentException if orientation is not one of VERTICAL, HORIZONTAL
  184. * @see #getOrientation
  185. * @beaninfo
  186. * preferred: true
  187. * bound: true
  188. * attribute: visualUpdate true
  189. * description: The scrollbar's orientation.
  190. * enum: VERTICAL JScrollBar.VERTICAL
  191. * HORIZONTAL JScrollBar.HORIZONTAL
  192. */
  193. public void setOrientation(int orientation)
  194. {
  195. checkOrientation(orientation);
  196. int oldValue = this.orientation;
  197. this.orientation = orientation;
  198. firePropertyChange("orientation", oldValue, orientation);
  199. if ((oldValue != orientation) && (accessibleContext != null)) {
  200. accessibleContext.firePropertyChange(
  201. AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
  202. ((oldValue == VERTICAL)
  203. ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL),
  204. ((orientation == VERTICAL)
  205. ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL));
  206. }
  207. if (orientation != oldValue) {
  208. revalidate();
  209. }
  210. }
  211. /**
  212. * Returns data model that handles the scrollbar's four
  213. * fundamental properties: minimum, maximum, value, extent.
  214. *
  215. * @see #setModel
  216. */
  217. public BoundedRangeModel getModel() {
  218. return model;
  219. }
  220. /**
  221. * Sets the model that handles the scrollbar's four
  222. * fundamental properties: minimum, maximum, value, extent.
  223. *
  224. * @see #getModel
  225. * @beaninfo
  226. * bound: true
  227. * expert: true
  228. * description: The scrollbar's BoundedRangeModel.
  229. */
  230. public void setModel(BoundedRangeModel newModel) {
  231. Integer oldValue = null;
  232. BoundedRangeModel oldModel = model;
  233. if (model != null) {
  234. model.removeChangeListener(fwdAdjustmentEvents);
  235. oldValue = new Integer(model.getValue());
  236. }
  237. model = newModel;
  238. if (model != null) {
  239. model.addChangeListener(fwdAdjustmentEvents);
  240. }
  241. firePropertyChange("model", oldModel, model);
  242. if (accessibleContext != null) {
  243. accessibleContext.firePropertyChange(
  244. AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
  245. oldValue, new Integer(model.getValue()));
  246. }
  247. }
  248. /**
  249. * Returns the amount to change the scrollbar's value by,
  250. * given a unit up/down request. A ScrollBarUI implementation
  251. * typically calls this method when the user clicks on a scrollbar
  252. * up/down arrow and uses the result to update the scrollbar's
  253. * value. Subclasses my override this method to compute
  254. * a value, e.g. the change required to scroll up or down one
  255. * (variable height) line text or one row in a table.
  256. * <p>
  257. * The JScrollPane component creates scrollbars (by default)
  258. * that override this method and delegate to the viewports
  259. * Scrollable view, if it has one. The Scrollable interface
  260. * provides a more specialized version of this method.
  261. *
  262. * @param direction is -1 or 1 for up/down respectively
  263. * @return the value of the unitIncrement property
  264. * @see #setUnitIncrement
  265. * @see #setValue
  266. * @see Scrollable#getScrollableUnitIncrement
  267. */
  268. public int getUnitIncrement(int direction) {
  269. return unitIncrement;
  270. }
  271. /**
  272. * Sets the unitIncrement property.
  273. * @see #getUnitIncrement
  274. * @beaninfo
  275. * preferred: true
  276. * bound: true
  277. * description: The scrollbar's unit increment.
  278. */
  279. public void setUnitIncrement(int unitIncrement) {
  280. int oldValue = this.unitIncrement;
  281. this.unitIncrement = unitIncrement;
  282. firePropertyChange("unitIncrement", oldValue, unitIncrement);
  283. }
  284. /**
  285. * Returns the amount to change the scrollbar's value by,
  286. * given a block (usually "page") up/down request. A ScrollBarUI
  287. * implementation typically calls this method when the user clicks
  288. * above or below the scrollbar "knob" to change the value
  289. * up or down by large amount. Subclasses my override this
  290. * method to compute a value, e.g. the change required to scroll
  291. * up or down one paragraph in a text document.
  292. * <p>
  293. * The JScrollPane component creates scrollbars (by default)
  294. * that override this method and delegate to the viewports
  295. * Scrollable view, if it has one. The Scrollable interface
  296. * provides a more specialized version of this method.
  297. *
  298. * @param direction is -1 or 1 for up/down respectively
  299. * @return the value of the blockIncrement property
  300. * @see #setBlockIncrement
  301. * @see #setValue
  302. * @see Scrollable#getScrollableBlockIncrement
  303. */
  304. public int getBlockIncrement(int direction) {
  305. return blockIncrement;
  306. }
  307. /**
  308. * Sets the blockIncrement property.
  309. * @see #getBlockIncrement()
  310. * @beaninfo
  311. * preferred: true
  312. * bound: true
  313. * description: The scrollbar's block increment.
  314. */
  315. public void setBlockIncrement(int blockIncrement) {
  316. int oldValue = this.blockIncrement;
  317. this.blockIncrement = blockIncrement;
  318. firePropertyChange("blockIncrement", oldValue, blockIncrement);
  319. }
  320. /**
  321. * For backwards compatibility with java.awt.Scrollbar.
  322. * @see Adjustable#getUnitIncrement
  323. * @see #getUnitIncrement(int)
  324. */
  325. public int getUnitIncrement() {
  326. return unitIncrement;
  327. }
  328. /**
  329. * For backwards compatibility with java.awt.Scrollbar.
  330. * @see Adjustable#getBlockIncrement
  331. * @see #getBlockIncrement(int)
  332. */
  333. public int getBlockIncrement() {
  334. return blockIncrement;
  335. }
  336. /**
  337. * Returns the scrollbar's value.
  338. * @return the model's value property
  339. * @see #setValue
  340. */
  341. public int getValue() {
  342. return getModel().getValue();
  343. }
  344. /**
  345. * Sets the scrollbar's value. This method just forwards the value
  346. * to the model.
  347. *
  348. * @see #getValue
  349. * @see BoundedRangeModel#setValue
  350. * @beaninfo
  351. * preferred: true
  352. * description: The scrollbar's current value.
  353. */
  354. public void setValue(int value) {
  355. BoundedRangeModel m = getModel();
  356. int oldValue = m.getValue();
  357. m.setValue(value);
  358. if (accessibleContext != null) {
  359. accessibleContext.firePropertyChange(
  360. AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
  361. new Integer(oldValue),
  362. new Integer(m.getValue()));
  363. }
  364. }
  365. /**
  366. * Returns the scrollbar's extent, aka its "visibleAmount". In many
  367. * scrollbar look and feel implementations the size of the
  368. * scrollbar "knob" or "thumb" is proportional to the extent.
  369. *
  370. * @return the value of the model's extent property
  371. * @see #setVisibleAmount
  372. */
  373. public int getVisibleAmount() {
  374. return getModel().getExtent();
  375. }
  376. /**
  377. * Set the model's extent property.
  378. *
  379. * @see #getVisibleAmount
  380. * @see BoundedRangeModel#setExtent
  381. * @beaninfo
  382. * preferred: true
  383. * description: The amount of the view that is currently visible.
  384. */
  385. public void setVisibleAmount(int extent) {
  386. getModel().setExtent(extent);
  387. }
  388. /**
  389. * Returns the minimum value supported by the scrollbar
  390. * (usually zero).
  391. *
  392. * @return the value of the model's minimum property
  393. * @see #setMinimum
  394. */
  395. public int getMinimum() {
  396. return getModel().getMinimum();
  397. }
  398. /**
  399. * Sets the model's minimum property.
  400. *
  401. * @see #getMinimum
  402. * @see BoundedRangeModel#setMinimum
  403. * @beaninfo
  404. * preferred: true
  405. * description: The scrollbar's minimum value.
  406. */
  407. public void setMinimum(int minimum) {
  408. getModel().setMinimum(minimum);
  409. }
  410. /**
  411. * The maximum value of the scrollbar is maximum - extent.
  412. *
  413. * @return the value of the model's maximum property
  414. * @see #setMaximum
  415. */
  416. public int getMaximum() {
  417. return getModel().getMaximum();
  418. }
  419. /**
  420. * Sets the model's maximum property. Note that the scrollbar's value
  421. * can only be set to maximum - extent.
  422. *
  423. * @see #getMaximum
  424. * @see BoundedRangeModel#setMaximum
  425. * @beaninfo
  426. * preferred: true
  427. * description: The scrollbar's maximum value.
  428. */
  429. public void setMaximum(int maximum) {
  430. getModel().setMaximum(maximum);
  431. }
  432. /**
  433. * True if the scrollbar knob is being dragged.
  434. *
  435. * @return the value of the model's valueIsAdjusting property
  436. * @see #setValueIsAdjusting
  437. */
  438. public boolean getValueIsAdjusting() {
  439. return getModel().getValueIsAdjusting();
  440. }
  441. /**
  442. * Sets the model's valueIsAdjusting property. Scrollbar look and
  443. * feel implementations should set this property to true when
  444. * a knob drag begins, and to false when the drag ends. The
  445. * scrollbar model will not generate ChangeEvents while
  446. * valueIsAdjusting is true.
  447. *
  448. * @see #getValueIsAdjusting
  449. * @see BoundedRangeModel#setValueIsAdjusting
  450. * @beaninfo
  451. * expert: true
  452. * description: True if the scrollbar thumb is being dragged.
  453. */
  454. public void setValueIsAdjusting(boolean b) {
  455. BoundedRangeModel m = getModel();
  456. boolean oldValue = m.getValueIsAdjusting();
  457. m.setValueIsAdjusting(b);
  458. if ((oldValue != b) && (accessibleContext != null)) {
  459. accessibleContext.firePropertyChange(
  460. AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
  461. ((oldValue) ? AccessibleState.BUSY : null),
  462. ((b) ? AccessibleState.BUSY : null));
  463. }
  464. }
  465. /**
  466. * Sets the four BoundedRangeModel properties after forcing
  467. * the arguments to obey the usual constraints:
  468. * <pre>
  469. * minimum <= value <= value+extent <= maximum
  470. * </pre>
  471. * <p>
  472. *
  473. * @see BoundedRangeModel#setRangeProperties
  474. * @see #setValue
  475. * @see #setVisibleAmount
  476. * @see #setMinimum
  477. * @see #setMaximum
  478. */
  479. public void setValues(int newValue, int newExtent, int newMin, int newMax)
  480. {
  481. BoundedRangeModel m = getModel();
  482. int oldValue = m.getValue();
  483. m.setRangeProperties(newValue, newExtent, newMin, newMax, m.getValueIsAdjusting());
  484. if (accessibleContext != null) {
  485. accessibleContext.firePropertyChange(
  486. AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
  487. new Integer(oldValue),
  488. new Integer(m.getValue()));
  489. }
  490. }
  491. /**
  492. * Adds an AdjustmentListener. Adjustment listeners are notified
  493. * each time the scrollbar's model changes. Adjustment events are
  494. * provided for backwards compatability with java.awt.Scrollbar.
  495. * <p>
  496. * Note that the AdjustmentEvents type property will always have a
  497. * placeholder value of AdjustmentEvent.TRACK because all changes
  498. * to a BoundedRangeModels value are considered equivalent. To change
  499. * the value of a BoundedRangeModel one just sets its value property,
  500. * i.e. model.setValue(123). No information about the origin of the
  501. * change, e.g. it's a block decrement, is provided. We don't try
  502. * fabricate the origin of the change here.
  503. *
  504. * @param l the AdjustmentLister to add
  505. * @see #removeAdjustmentListener
  506. * @see BoundedRangeModel#addChangeListener
  507. */
  508. public void addAdjustmentListener(AdjustmentListener l) {
  509. listenerList.add(AdjustmentListener.class, l);
  510. }
  511. /**
  512. * Removes an AdjustmentEvent listener.
  513. *
  514. * @param l the AdjustmentLister to remove
  515. * @see #addAdjustmentListener
  516. */
  517. public void removeAdjustmentListener(AdjustmentListener l) {
  518. listenerList.remove(AdjustmentListener.class, l);
  519. }
  520. /*
  521. * Notify listeners that the scrollbar's model has changed.
  522. *
  523. * @see #addAdjustmentListener
  524. * @see EventListenerList
  525. */
  526. protected void fireAdjustmentValueChanged(int id, int type, int value) {
  527. Object[] listeners = listenerList.getListenerList();
  528. AdjustmentEvent e = null;
  529. for (int i = listeners.length - 2; i >= 0; i -= 2) {
  530. if (listeners[i]==AdjustmentListener.class) {
  531. if (e == null) {
  532. e = new AdjustmentEvent(this, id, type, value);
  533. }
  534. ((AdjustmentListener)listeners[i+1]).adjustmentValueChanged(e);
  535. }
  536. }
  537. }
  538. /**
  539. * This class listens to ChangeEvents on the model and forwards
  540. * AdjustmentEvents for the sake of backwards compatibility.
  541. * Unfortunately there's no way to determine the proper
  542. * type of the AdjustmentEvent as all updates to the model's
  543. * value are considered equivalent.
  544. */
  545. private class ModelListener implements ChangeListener, Serializable {
  546. public void stateChanged(ChangeEvent e) {
  547. int id = AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED;
  548. int type = AdjustmentEvent.TRACK;
  549. fireAdjustmentValueChanged(id, type, getValue());
  550. }
  551. }
  552. // PENDING(hmuller) - the next three methods should be removed
  553. /**
  554. * The scrollbar is flexible along it's scrolling axis and
  555. * rigid along the other axis.
  556. */
  557. public Dimension getMinimumSize() {
  558. Dimension pref = getPreferredSize();
  559. if (orientation == VERTICAL) {
  560. return new Dimension(pref.width, 5);
  561. } else {
  562. return new Dimension(5, pref.height);
  563. }
  564. }
  565. /**
  566. * The scrollbar is flexible along it's scrolling axis and
  567. * rigid along the other axis.
  568. */
  569. public Dimension getMaximumSize() {
  570. Dimension pref = getPreferredSize();
  571. if (getOrientation() == VERTICAL) {
  572. return new Dimension(pref.width, Short.MAX_VALUE);
  573. } else {
  574. return new Dimension(Short.MAX_VALUE, pref.height);
  575. }
  576. }
  577. /**
  578. * Enables the component so that the knob position can be changed.
  579. * When the disabled, the knob position cannot be changed.
  580. *
  581. * @param b a boolean value, where true enables the component and
  582. * false disables it
  583. */
  584. public void setEnabled(boolean x) {
  585. super.setEnabled(x);
  586. Component[] children = getComponents();
  587. for(int i = 0; i < children.length; i++) {
  588. children[i].setEnabled(x);
  589. }
  590. }
  591. /**
  592. * See readObject() and writeObject() in JComponent for more
  593. * information about serialization in Swing.
  594. */
  595. private void writeObject(ObjectOutputStream s) throws IOException {
  596. s.defaultWriteObject();
  597. if ((ui != null) && (getUIClassID().equals(uiClassID))) {
  598. ui.installUI(this);
  599. }
  600. }
  601. /**
  602. * Returns a string representation of this JScrollBar. This method
  603. * is intended to be used only for debugging purposes, and the
  604. * content and format of the returned string may vary between
  605. * implementations. The returned string may be empty but may not
  606. * be <code>null</code>.
  607. *
  608. * @return a string representation of this JScrollBar.
  609. */
  610. protected String paramString() {
  611. String orientationString = (orientation == HORIZONTAL ?
  612. "HORIZONTAL" : "VERTICAL");
  613. return super.paramString() +
  614. ",blockIncrement=" + blockIncrement +
  615. ",orientation=" + orientationString +
  616. ",unitIncrement=" + unitIncrement;
  617. }
  618. /////////////////
  619. // Accessibility support
  620. ////////////////
  621. /**
  622. * Get the AccessibleContext associated with this JComponent
  623. *
  624. * @return the AccessibleContext of this JComponent
  625. */
  626. public AccessibleContext getAccessibleContext() {
  627. if (accessibleContext == null) {
  628. accessibleContext = new AccessibleJScrollBar();
  629. }
  630. return accessibleContext;
  631. }
  632. /**
  633. * The class used to obtain the accessible role for this object.
  634. * <p>
  635. * <strong>Warning:</strong>
  636. * Serialized objects of this class will not be compatible with
  637. * future Swing releases. The current serialization support is appropriate
  638. * for short term storage or RMI between applications running the same
  639. * version of Swing. A future release of Swing will provide support for
  640. * long term persistence.
  641. */
  642. protected class AccessibleJScrollBar extends AccessibleJComponent
  643. implements AccessibleValue {
  644. /**
  645. * Get the state set of this object.
  646. *
  647. * @return an instance of AccessibleState containing the current state
  648. * of the object
  649. * @see AccessibleState
  650. */
  651. public AccessibleStateSet getAccessibleStateSet() {
  652. AccessibleStateSet states = super.getAccessibleStateSet();
  653. if (getValueIsAdjusting()) {
  654. states.add(AccessibleState.BUSY);
  655. }
  656. if (getOrientation() == VERTICAL) {
  657. states.add(AccessibleState.VERTICAL);
  658. } else {
  659. states.add(AccessibleState.HORIZONTAL);
  660. }
  661. return states;
  662. }
  663. /**
  664. * Get the role of this object.
  665. *
  666. * @return an instance of AccessibleRole describing the role of the
  667. * object
  668. */
  669. public AccessibleRole getAccessibleRole() {
  670. return AccessibleRole.SCROLL_BAR;
  671. }
  672. /**
  673. * Get the AccessibleValue associated with this object if one
  674. * exists. Otherwise return null.
  675. */
  676. public AccessibleValue getAccessibleValue() {
  677. return this;
  678. }
  679. /**
  680. * Get the accessible value of this object.
  681. *
  682. * @return The current value of this object.
  683. */
  684. public Number getCurrentAccessibleValue() {
  685. return new Integer(getValue());
  686. }
  687. /**
  688. * Set the value of this object as a Number.
  689. *
  690. * @return True if the value was set.
  691. */
  692. public boolean setCurrentAccessibleValue(Number n) {
  693. if (n instanceof Integer) {
  694. setValue(n.intValue());
  695. return true;
  696. } else {
  697. return false;
  698. }
  699. }
  700. /**
  701. * Get the minimum accessible value of this object.
  702. *
  703. * @return The minimum value of this object.
  704. */
  705. public Number getMinimumAccessibleValue() {
  706. return new Integer(getMinimum());
  707. }
  708. /**
  709. * Get the maximum accessible value of this object.
  710. *
  711. * @return The maximum value of this object.
  712. */
  713. public Number getMaximumAccessibleValue() {
  714. return new Integer(getMaximum());
  715. }
  716. } // AccessibleJScrollBar
  717. }