home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / swing / JSplitPane.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  22.9 KB  |  726 lines

  1. /*
  2.  * @(#)JSplitPane.java    1.32 98/02/03
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package java.awt.swing;
  22.  
  23. import java.awt.*;
  24. import java.awt.swing.border.Border;
  25. import java.awt.swing.plaf.*;
  26. import java.awt.accessibility.*;
  27.  
  28. /**
  29.   * JSplitPane is used to divide two (and only two) Components. The two
  30.   * Components are graphically divided based on the look and feel
  31.   * implementation. By user intervention the two Components can be
  32.   * interactively resized.
  33.   * <p>
  34.   * The two Components can be aligned left to right,
  35.   * <code>JSplitPane.HORIZONTAL_SPLIT</code>, or top to bottom, 
  36.   * <code>JSplitPane.VERTICAL_SPLIT</code>.
  37.   * The preferred way to change the size of the Componets is to invoke
  38.   * setDividerLocation where location is either the new x or y position
  39.   * depending on the orientation of the JSplitPane. JSplitPane will also
  40.   * try and reposition the other Component if one changes.
  41.   * <p>
  42.   * To resize the Components to their preferred sizes invoke
  43.   * resetPreferredSizes.
  44.   * <p>
  45.   * When the user is resizing the Components the minimum size of the
  46.   * Components is used to determine the maximum/minimum position the
  47.   * Components can be set to. So that if the minimum size of the two
  48.   * components is greater than the size of the splitpane the divider
  49.   * will not allow you to resize it. Refer to JComponent.setMinimumSize
  50.   * for a way to alter the minimum size of a JComponent.
  51.   * <p>
  52.   * Warning: serialized objects of this class will not be compatible with
  53.   * future swing releases.  The current serialization support is appropriate
  54.   * for short term storage or RMI between Swing1.0 applications.  It will
  55.   * not be possible to load serialized Swing1.0 objects with future releases
  56.   * of Swing.  The JDK1.2 release of Swing will be the compatibility
  57.   * baseline for the serialized form of Swing objects.
  58.   *
  59.   * @version 1.32 02/03/98
  60.   * @author Scott Violet
  61.   */
  62. public class JSplitPane extends JComponent implements Accessible
  63. {
  64.     /** Vertical split indicates the Components are split along the
  65.       * y axis, eg the two Components will be split one on top of the other. */
  66.     public final static int        VERTICAL_SPLIT = 0;
  67.     /** Horizontal split indicates the Components are split along the
  68.       * x axis, eg the two Components will be split one to the left of the
  69.       * other. */
  70.     public final static int        HORIZONTAL_SPLIT = 1;
  71.  
  72.     /** Used to add a Component to go on the left side of the other
  73.       * Component. */
  74.     public final static String     LEFT = "left";
  75.     /** Used to add a Component to go on the right side of the other
  76.       * Component. */
  77.     public final static String     RIGHT = "right";
  78.     /** Used to add a Component above the other Component. */
  79.     public final static String     TOP = "top";
  80.     /** Used to add a Component below the other Component. */
  81.     public final static String     BOTTOM = "bottom";
  82.     /** Used to add a Component that will represent the divider. */
  83.     public final static String     DIVIDER = "divider";
  84.  
  85.     /** Bound property name for orientation. */
  86.     public final static String ORIENTATION_PROPERTY = "orientation";
  87.     /** Bound property name for continuousLayout. */
  88.     public final static String CONTINUOUS_LAYOUT_PROPERTY = "continuousLayout";
  89.     /** Bound property name for border. */
  90.     public final static String DIVIDER_SIZE_PROPERTY = "dividerSize";
  91.     /** Bound property for oneTouchExpandable. */
  92.     public final static String ONE_TOUCH_EXPANDABLE_PROPERTY = 
  93.                            "oneTouchExpandable";
  94.     /** Bound property for lastLocation. */
  95.     public final static String LAST_DIVIDER_LOCATION_PROPERTY =
  96.                            "lastDividerLocation";
  97.  
  98.     /** How the views are split. */
  99.     protected int            orientation;
  100.  
  101.     /** Whether or not the views are continuously redisplayed while
  102.       * resizing. */
  103.     protected boolean        continuousLayout;
  104.  
  105.     /** The left or top component. */
  106.     protected Component      leftComponent;
  107.  
  108.     /* The right or bottom component. */
  109.     protected Component      rightComponent;
  110.  
  111.     /** Size of the divider. */
  112.     protected int            dividerSize;
  113.  
  114.     /** Is a little widget provided to quickly expand/collapse the
  115.      * split pane. */
  116.     protected boolean        oneTouchExpandable;
  117.  
  118.     /** Previous location of the split pane. */
  119.     protected int            lastDividerLocation;
  120.  
  121.     /**
  122.       * Returns a new JSplitPane configured to vertically divide
  123.       * the child components and with two buttons.
  124.       */
  125.     public JSplitPane() {
  126.     this(JSplitPane.HORIZONTAL_SPLIT, false, new JButton("left button"),
  127.          new JButton("right button"));
  128.     }
  129.  
  130.     /**
  131.       * Returns a new JSplitPane configured with the passed in orientation
  132.       * and no continuous layout.
  133.       */
  134.     public JSplitPane(int newOrientation) {
  135.     this(newOrientation, false);
  136.     }
  137.  
  138.     /**
  139.       * Returns a new JSplitPane with the specified orientation and
  140.       * continuousLayout.
  141.       */
  142.     public JSplitPane(int newOrientation, boolean newContinuousLayout) {
  143.     this(newOrientation, newContinuousLayout, null, null);
  144.     }
  145.  
  146.     /**
  147.       * Returns a new JSplitPane with the specified orientation, 
  148.       * continuousLayout and passed in Components.
  149.       */
  150.     public JSplitPane(int newOrientation,
  151.               Component newLeftComponent, Component newRightComponent){
  152.     this(newOrientation, false, newLeftComponent, newRightComponent);
  153.     }
  154.  
  155.     /**
  156.       * Returns a new JSplitPane with the specified orientation, 
  157.       * continuousLayout and passed in Components.
  158.       */
  159.     public JSplitPane(int newOrientation, boolean newContinuousLayout,
  160.               Component newLeftComponent, Component newRightComponent){
  161.     super();
  162.     dividerSize = 5;
  163.     setLayout(null);
  164.     orientation = newOrientation;
  165.     if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)
  166.         throw new IllegalArgumentException("cannot create JSplitPane, orientation must be one of JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT");
  167.     continuousLayout = newContinuousLayout;
  168.     if (newLeftComponent != null)
  169.         setLeftComponent(newLeftComponent);
  170.     if (newRightComponent != null)
  171.         setRightComponent(newRightComponent);
  172.     updateUI();
  173.     }
  174.  
  175.     /**
  176.       * Sets the TreeUI that will provide the current look and feel.
  177.       */
  178.     public void setUI(SplitPaneUI ui) {
  179.         if ((SplitPaneUI)this.ui != ui) {
  180.             super.setUI(ui);
  181.             invalidate();
  182.         }
  183.     }
  184.  
  185.     /**
  186.       * Returns the SplitPaneUI that is providing the current look and 
  187.       * feel. 
  188.       * @beaninfo
  189.       *      expert: true
  190.       *  description: The L&F object that renders this component.
  191.       */
  192.     public SplitPaneUI getUI() {
  193.     return (SplitPaneUI)ui;
  194.     }
  195.  
  196.     /**
  197.      * Called to replace the UI with the latest version from the 
  198.      * default UIFactory.
  199.      */
  200.     public void updateUI() {
  201.     setUI((SplitPaneUI)UIManager.getUI(this));
  202.     invalidate();
  203.     }
  204.  
  205.  
  206.     /**
  207.      * @return "SplitPaneUI"
  208.      * @see JComponent#getUIClassID
  209.      * @see UIDefaults#getUI
  210.      * @beaninfo
  211.      *        expert: true
  212.      *   description: A string that specifies the name of the L&F class.
  213.      */
  214.     public String getUIClassID() {
  215.     return "SplitPaneUI";
  216.     }
  217.  
  218.  
  219.     /**
  220.      * Sets the size of the divider to <code>newSize</code>.
  221.      * @beaninfo
  222.      *        bound: true
  223.      *  description: The size of the divider.
  224.      */
  225.     public void setDividerSize(int newSize) {
  226.     int           oldSize = dividerSize;
  227.  
  228.         if (oldSize != newSize) {
  229.             dividerSize = newSize;
  230.             firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, newSize);
  231.         }
  232.     }
  233.  
  234.     /**
  235.      * Returns the size of the divider.
  236.      */
  237.     public int getDividerSize() {
  238.     return dividerSize;
  239.     }
  240.  
  241.     /**
  242.       * Sets the component to the left (or above) the divider.
  243.       */
  244.     public void setLeftComponent(Component comp) {
  245.     if (comp == null) {
  246.         if (leftComponent != null) {
  247.         remove(leftComponent);
  248.         leftComponent = null;
  249.         }
  250.     } else {
  251.         add(comp, JSplitPane.LEFT);
  252.         }
  253.     }
  254.  
  255.     /**
  256.       * Returns the component to the left (or above) the divider.
  257.       * @beaninfo
  258.       *  preferred: true
  259.       *  description: The component to the left (or above) the divider.
  260.       */
  261.     public Component getLeftComponent() {
  262.     return leftComponent;
  263.     }
  264.  
  265.     /**
  266.       * Sets the component above, or to the left of the divider.
  267.       * @beaninfo
  268.       *  description: The component above, or to the left of the divider.
  269.       */
  270.     public void setTopComponent(Component comp) {
  271.     setLeftComponent(comp);
  272.     }
  273.  
  274.     /**
  275.       * Returns the component above, or to the left of the divider.
  276.       */
  277.     public Component getTopComponent() {
  278.     return leftComponent;
  279.     }
  280.  
  281.     /**
  282.       * Sets the component to the right (or below) the divider.
  283.       * @beaninfo
  284.       *    preferred: true
  285.       *  description: The component to the right (or below) the divider.
  286.       */
  287.     public void setRightComponent(Component comp) {
  288.     if (comp == null) {
  289.         if (rightComponent != null) {
  290.         remove(rightComponent);
  291.         rightComponent = null;
  292.         }
  293.     } else {
  294.         add(comp, JSplitPane.RIGHT);
  295.         }
  296.     }
  297.  
  298.     /**
  299.       * Returns the component to the right (or below) the divider.
  300.       */
  301.     public Component getRightComponent() {
  302.     return rightComponent;
  303.     }
  304.  
  305.     /**
  306.       * Sets the component below, or to the right of the divider.
  307.       * @beaninfo
  308.       *  description: The component below, or to the right of the divider.
  309.       */
  310.     public void setBottomComponent(Component comp) {
  311.     setRightComponent(comp);
  312.     }
  313.  
  314.     /**
  315.       * Returns the component below, or to the right of the divider.
  316.       */
  317.     public Component getBottomComponent() {
  318.     return rightComponent;
  319.     }
  320.  
  321.     /**
  322.      * If <code>newValue</code> is true, the reciever will provide
  323.      * UI widgets on the divider to quickly expand/collapse the
  324.      * divider.
  325.      * @beaninfo
  326.      *        bound: true
  327.      *  description: UI widget on the divider to quickly 
  328.      *               expand/collapse the divider.
  329.      */
  330.     public void setOneTouchExpandable(boolean newValue) {
  331.     boolean           oldValue = oneTouchExpandable;
  332.  
  333.     oneTouchExpandable = newValue;
  334.     firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, newValue);
  335.     repaint();
  336.     }
  337.  
  338.     /**
  339.      * Returns true if the receiver provides a UI widget to collapse/expand
  340.      * the divider.
  341.      */
  342.     public boolean isOneTouchExpandable() {
  343.     return oneTouchExpandable;
  344.     }
  345.  
  346.     /**
  347.      * Sets the last location the divider was at to
  348.      * <code>newLastLocation</code>.
  349.      * @beaninfo
  350.      *        bound: true
  351.      *  description: The last location the divider was at.
  352.      */
  353.     public void setLastDividerLocation(int newLastLocation) {
  354.     int               oldLocation = lastDividerLocation;
  355.  
  356.     lastDividerLocation = newLastLocation;
  357.     firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldLocation,
  358.                newLastLocation);
  359.     }
  360.     
  361.     /**
  362.      * Returns the last location the divider was at.
  363.      */
  364.     public int getLastDividerLocation() {
  365.     return lastDividerLocation;
  366.     }
  367.  
  368.     /**
  369.       * Sets the orientation, or how the splitter is divided.
  370.       * @beaninfo
  371.       *        bound: true
  372.       *  description: The orientation, or how the splitter is divided.
  373.       */
  374.     public void setOrientation(int orientation) {
  375.     if (orientation != VERTICAL_SPLIT && orientation != HORIZONTAL_SPLIT) {
  376.        throw new IllegalArgumentException("JSplitPane: orientation must be one of JSplitPane.VERTICAL_SPLIT or JSplitPane.HORIZONTAL_SPLIT");
  377.         }
  378.  
  379.     int           oldOrientation = this.orientation;
  380.  
  381.     this.orientation = orientation;
  382.     firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, orientation);
  383.     }
  384.  
  385.     /**
  386.       * Returns the orientation.
  387.       */
  388.     public int getOrientation() {
  389.     return orientation;
  390.     }
  391.  
  392.     /**
  393.       * Sets whether or not the child components are continuously
  394.       * redisplayed and layed out during user intervention.
  395.       * @beaninfo
  396.       *        bound: true
  397.       *  description: Whether or not the child components are
  398.       *               continuously redisplayed and layed out during
  399.       *               user intervention.
  400.       */
  401.     public void setContinuousLayout(boolean newContinuousLayout) {
  402.     boolean           oldCD = continuousLayout;
  403.  
  404.     continuousLayout = newContinuousLayout;
  405.     firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldCD,
  406.                newContinuousLayout);
  407.     }
  408.  
  409.     /**
  410.       * Returns true if the child comopnents are continuously redisplayed and
  411.       * layed out during user intervention.
  412.       */
  413.     public boolean isContinuousLayout() {
  414.     return continuousLayout;
  415.     }
  416.  
  417.     /**
  418.       * Messaged to relayout the JSplitPane based on the preferred size
  419.       * of the children components.
  420.       */
  421.     public void resetToPreferredSizes() {
  422.     SplitPaneUI         ui = getUI();
  423.  
  424.     if (ui != null) {
  425.         ui.resetToPreferredSizes();
  426.         }
  427.     }
  428.  
  429.     /**
  430.       * Messages the receiver with setDividerLocation(proportionalLocation *
  431.       * size). Where size is either getWidth() or getHeight(). This will
  432.       * throw an IllegalArgumentException if <code>proportionalLocation</code>
  433.       * is < 0 or > 1.0.
  434.       * @beaninfo
  435.       *  description: The location of the divider.
  436.       */
  437.     public void setDividerLocation(double proportionalLocation) {
  438.     if (proportionalLocation < 0.0 || 
  439.        proportionalLocation > 1.0) {
  440.         throw new IllegalArgumentException("proportional location must be between 0.0 and 1.0.");
  441.         }
  442.     if (getOrientation() == VERTICAL_SPLIT) {
  443.         setDividerLocation((int)((double)(getHeight() - getDividerSize()) *
  444.                      proportionalLocation));
  445.     } else {
  446.         setDividerLocation((int)((double)(getWidth() - getDividerSize()) *
  447.                      proportionalLocation));
  448.         }
  449.     }
  450.  
  451.     /**
  452.       * Sets the location of the divider. This is passed off to the 
  453.       * look and feel implementation.
  454.       */
  455.     public void setDividerLocation(int location) {
  456.     SplitPaneUI         ui = getUI();
  457.  
  458.     if (ui != null) {
  459.         ui.setDividerLocation(location);
  460.         }
  461.     }
  462.  
  463.     /**
  464.       * Returns the location of the divider from the look and feel
  465.       * implementation.
  466.       */
  467.     public int getDividerLocation() {
  468.     SplitPaneUI         ui = getUI();
  469.  
  470.     if (ui != null) {
  471.         return ui.getDividerLocation();
  472.         }
  473.     return -1;
  474.     }
  475.  
  476.  
  477.     /**
  478.       * Returns the minimum location of the divider from the look and feel
  479.       * implementation.
  480.       * @beaninfo
  481.       *  description: The minimum location of the divider from the L&F.
  482.       */
  483.     public int getMinimumDividerLocation() {
  484.     SplitPaneUI         ui = getUI();
  485.  
  486.     if (ui != null) {
  487.         return ui.getMinimumDividerLocation();
  488.         }
  489.     return -1;
  490.     }
  491.  
  492.  
  493.     /**
  494.       * Returns the maximum location of the divider from the look and feel
  495.       * implementation.
  496.       */
  497.     public int getMaximumDividerLocation() {
  498.     SplitPaneUI         ui = getUI();
  499.  
  500.     if (ui != null) {
  501.         return ui.getMaximumDividerLocation();
  502.         }
  503.     return -1;
  504.     }
  505.  
  506.     /**
  507.      * Removes the child component, <code>component</code> from the
  508.      * receiver. Reset the leftComponent or rightComponent instance
  509.      * variable if necessary.
  510.      */
  511.     public void remove(Component component) {
  512.     if (component == leftComponent) {
  513.         leftComponent = null;
  514.     } else if (component == rightComponent) {
  515.         rightComponent = null;
  516.         }
  517.     super.remove(component);
  518.     }
  519.  
  520.     /**
  521.      * Removes the Component at the passed in index. This updates the
  522.      * leftComponent and rightComponent ivars if necessary, and then
  523.      * messages super.
  524.      */
  525.     public void remove(int index) {
  526.     Component    comp = getComponent(index);
  527.  
  528.     if (comp == leftComponent) {
  529.         leftComponent = null;
  530.     } else if (comp == rightComponent) {
  531.         rightComponent = null;
  532.         }
  533.     super.remove(index);
  534.     }
  535.  
  536.     /**
  537.      * Removes all the child components from the receiver. Resets the
  538.      * leftComonent and rightComponent instance variables.
  539.      */
  540.     public void removeAll() {
  541.     leftComponent = rightComponent = null;
  542.     super.removeAll();
  543.     }
  544.  
  545.     /**
  546.      * If <code>constraints</code> identifies the left/top or
  547.      * right/bottom child component, and a component with that identifier
  548.      * was previously added, it will be removed and then <code>comp</code>
  549.      * will be added in its place. If <code>constraints</code> is not
  550.      * one of the known identifers the layout manager may throw an
  551.      * IllegalArgumentException.
  552.       */
  553.     protected void addImpl(Component comp, Object constraints, int index) 
  554.     {
  555.     Component             toRemove;
  556.  
  557.     if (constraints != null && !(constraints instanceof String)) {
  558.         throw new IllegalArgumentException("cannot add to layout: constraint must be a string (or null)");
  559.         }
  560.  
  561.     /* If the constraints are null and the left/right component is
  562.        invalid, add it at the left/right component. */
  563.     if (constraints == null) {
  564.         if (getLeftComponent() == null) {
  565.         constraints = JSplitPane.LEFT;
  566.         } else if (getRightComponent() == null) {
  567.         constraints = JSplitPane.RIGHT;
  568.             }
  569.     }
  570.         
  571.     /* Find the Component that already exists and remove it. */
  572.     if (constraints != null && (constraints.equals(JSplitPane.LEFT) ||
  573.                    constraints.equals(JSplitPane.TOP))) {
  574.         toRemove = getLeftComponent();
  575.         if (toRemove != null) {
  576.         remove(toRemove);
  577.             }
  578.         leftComponent = comp;
  579.         index = -1;
  580.     } else if (constraints != null && (constraints.equals(JSplitPane.RIGHT) ||
  581.                       constraints.equals(JSplitPane.BOTTOM))) {
  582.         toRemove = getRightComponent();
  583.         if (toRemove != null) {
  584.         remove(toRemove);
  585.             }
  586.         rightComponent = comp;
  587.         index = -1;
  588.     } else if (constraints != null &&
  589.         constraints.equals(JSplitPane.DIVIDER)) {
  590.         index = -1;
  591.     }
  592.     /* LayoutManager should raise for else condition here. */
  593.  
  594.     super.addImpl(comp, constraints, index);
  595.     }
  596.  
  597.     /**
  598.       * Subclassed to message the UI with finishedPaintingChildren after
  599.       * super has been messaged, as well as painting the border.
  600.       */
  601.     protected void paintChildren(Graphics g) {
  602.     super.paintChildren(g);
  603.  
  604.     SplitPaneUI        ui = getUI();
  605.  
  606.     if (ui != null) {
  607.         Graphics           tempG = g.create();
  608.         ui.finishedPaintingChildren(this, tempG);
  609.         tempG.dispose();
  610.     }
  611.     }
  612.  
  613. /////////////////
  614. // Accessibility support
  615. ////////////////
  616.  
  617.     /**
  618.      * Get the AccessibleContext associated with this JComponent
  619.      *
  620.      * @return the AccessibleContext of this JComponent
  621.      * @beaninfo
  622.      *       expert: true
  623.      *  description: The AccessibleContext associated with this Label.
  624.      */
  625.     public AccessibleContext getAccessibleContext() {
  626.     if (accessibleContext == null) {
  627.         accessibleContext = new AccessibleJSplitPane();
  628.     }
  629.     return accessibleContext;
  630.     }
  631.  
  632.     /**
  633.      * The class used to obtain the accessible role for this object.
  634.      * <p>
  635.      * Warning: serialized objects of this class will not be compatible with
  636.      * future swing releases.  The current serialization support is appropriate
  637.      * for short term storage or RMI between Swing1.0 applications.  It will
  638.      * not be possible to load serialized Swing1.0 objects with future releases
  639.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  640.      * baseline for the serialized form of Swing objects.
  641.      */
  642.     protected class AccessibleJSplitPane extends AccessibleJComponent 
  643.     implements AccessibleValue {
  644.  
  645.         /**
  646.          * Get the state set of this object.
  647.          *
  648.          * @return an instance of AccessibleState containing the current state 
  649.          * of the object
  650.          * @see AccessibleState
  651.          */
  652.         public AccessibleStateSet getAccessibleStateSet() {
  653.             AccessibleStateSet states = super.getAccessibleStateSet();
  654.             // FIXME: [[[WDW - Should also add BUSY if this implements
  655.             // Adjustable at some point.  If this happens, we probably
  656.             // should also add actions.]]]
  657.             if (getOrientation() == VERTICAL_SPLIT) {
  658.                 states.add(AccessibleState.VERTICAL);
  659.             } else {
  660.                 states.add(AccessibleState.HORIZONTAL);
  661.             }
  662.             return states;
  663.         }
  664.     
  665.         /**
  666.          * Get the AccessibleValue associated with this object if one
  667.          * exists.  Otherwise return null.
  668.          */
  669.         public AccessibleValue getAccessibleValue() {
  670.         return this;
  671.         }
  672.  
  673.         /**
  674.          * Get the accessible value of this object.
  675.          *
  676.          * @return a localized String describing the value of this object
  677.          */
  678.         public Number getCurrentAccessibleValue() {
  679.             return new Integer(getDividerLocation());
  680.         }
  681.     
  682.         /**
  683.          * Set the value of this object as a Number.
  684.          *
  685.          * @return True if the value was set.
  686.          */
  687.         public boolean setCurrentAccessibleValue(Number n) {
  688.             if (n instanceof Integer) {
  689.                 setDividerLocation(n.intValue());
  690.                 return true;
  691.             } else {
  692.                 return false;
  693.             }
  694.         }
  695.     
  696.         /**
  697.          * Get the minimum accessible value of this object.
  698.          *
  699.          * @return The minimum value of this object.
  700.          */
  701.         public Number getMinimumAccessibleValue() {
  702.             return new Integer(getUI().getMinimumDividerLocation());
  703.         }
  704.     
  705.         /**
  706.          * Get the maximum accessible value of this object.
  707.          *
  708.          * @return The maximum value of this object.
  709.          */
  710.         public Number getMaximumAccessibleValue() {
  711.             return new Integer(getUI().getMaximumDividerLocation());
  712.         }
  713.     
  714.         /**
  715.          * Get the role of this object.
  716.          *
  717.          * @return an instance of AccessibleRole describing the role of 
  718.      * the object
  719.          * @see AccessibleRole
  720.          */
  721.         public AccessibleRole getAccessibleRole() {
  722.             return AccessibleRole.SPLIT_PANE;
  723.         }
  724.     } // inner class AccessibleJSplitPane
  725. }
  726.