jdk/src/share/classes/javax/swing/JSplitPane.java
author anthony
Wed, 21 Oct 2009 17:06:41 +0400
changeset 4261 126dc6fe0d7b
parent 2658 43e06bc950ec
child 5135 99420aad4834
permissions -rw-r--r--
6852592: invalidate() must be smarter Summary: Introduce validate roots in AWT Reviewed-by: alexp, art, dcherepanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 438
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.beans.ConstructorProperties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <code>JSplitPane</code> is used to divide two (and only two)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <code>Component</code>s. The two <code>Component</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * are graphically divided based on the look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * implementation, and the two <code>Component</code>s can then be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * interactively resized by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Information on using <code>JSplitPane</code> is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 href="http://java.sun.com/docs/books/tutorial/uiswing/components/splitpane.html">How to Use Split Panes</a> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * The two <code>Component</code>s in a split pane can be aligned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * left to right using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <code>JSplitPane.HORIZONTAL_SPLIT</code>, or top to bottom using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <code>JSplitPane.VERTICAL_SPLIT</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * The preferred way to change the size of the <code>Component</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * is to invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <code>setDividerLocation</code> where <code>location</code> is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * the new x or y position, depending on the orientation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <code>JSplitPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * To resize the <code>Component</code>s to their preferred sizes invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <code>resetToPreferredSizes</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * When the user is resizing the <code>Component</code>s the minimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * size of the <code>Components</code> is used to determine the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * maximum/minimum position the <code>Component</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * can be set to. If the minimum size of the two
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * components is greater than the size of the split pane the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * will not allow you to resize it. To alter the minimum size of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <code>JComponent</code>, see {@link JComponent#setMinimumSize}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * When the user resizes the split pane the new space is distributed between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * the two components based on the <code>resizeWeight</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * A value of 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * the default, indicates the right/bottom component gets all the space,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * where as a value of 1 indicates the left/top component gets all the space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * @see #setDividerLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * @see #resetToPreferredSizes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
public class JSplitPane extends JComponent implements Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private static final String uiClassID = "SplitPaneUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Vertical split indicates the <code>Component</code>s are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * split along the y axis.  For example the two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * <code>Component</code>s will be split one on top of the other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public final static int VERTICAL_SPLIT = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Horizontal split indicates the <code>Component</code>s are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * split along the x axis.  For example the two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * <code>Component</code>s will be split one to the left of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public final static int HORIZONTAL_SPLIT = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Used to add a <code>Component</code> to the left of the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public final static String LEFT = "left";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Used to add a <code>Component</code> to the right of the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public final static String RIGHT = "right";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Used to add a <code>Component</code> above the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public final static String TOP = "top";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Used to add a <code>Component</code> below the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public final static String BOTTOM = "bottom";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Used to add a <code>Component</code> that will represent the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public final static String DIVIDER = "divider";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Bound property name for orientation (horizontal or vertical).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public final static String ORIENTATION_PROPERTY = "orientation";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Bound property name for continuousLayout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public final static String CONTINUOUS_LAYOUT_PROPERTY = "continuousLayout";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Bound property name for border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public final static String DIVIDER_SIZE_PROPERTY = "dividerSize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Bound property for oneTouchExpandable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public final static String ONE_TOUCH_EXPANDABLE_PROPERTY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                               "oneTouchExpandable";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Bound property for lastLocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public final static String LAST_DIVIDER_LOCATION_PROPERTY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                               "lastDividerLocation";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Bound property for the dividerLocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public final static String DIVIDER_LOCATION_PROPERTY = "dividerLocation";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Bound property for weight.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public final static String RESIZE_WEIGHT_PROPERTY = "resizeWeight";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * How the views are split.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    protected int orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Whether or not the views are continuously redisplayed while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * resizing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    protected boolean continuousLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * The left or top component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    protected Component leftComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * The right or bottom component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    protected Component rightComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Size of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    protected int dividerSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    private boolean dividerSizeSet = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Is a little widget provided to quickly expand/collapse the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * split pane?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    protected boolean oneTouchExpandable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private boolean oneTouchExpandableSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Previous location of the split pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    protected int lastDividerLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * How to distribute extra space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private double resizeWeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Location of the divider, at least the value that was set, the UI may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * have a different value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    private int dividerLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Creates a new <code>JSplitPane</code> configured to arrange the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * components side-by-side horizontally with no continuous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * layout, using two buttons for the components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public JSplitPane() {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   249
        this(JSplitPane.HORIZONTAL_SPLIT,
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   250
            UIManager.getBoolean("SplitPane.continuousLayout"),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            new JButton(UIManager.getString("SplitPane.leftButtonText")),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            new JButton(UIManager.getString("SplitPane.rightButtonText")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Creates a new <code>JSplitPane</code> configured with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * specified orientation and no continuous layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @param newOrientation  <code>JSplitPane.HORIZONTAL_SPLIT</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *                        <code>JSplitPane.VERTICAL_SPLIT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @exception IllegalArgumentException if <code>orientation</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *          is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    @ConstructorProperties({"orientation"})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public JSplitPane(int newOrientation) {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   267
        this(newOrientation,
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   268
            UIManager.getBoolean("SplitPane.continuousLayout"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Creates a new <code>JSplitPane</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * orientation and redrawing style.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param newOrientation  <code>JSplitPane.HORIZONTAL_SPLIT</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *                        <code>JSplitPane.VERTICAL_SPLIT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param newContinuousLayout  a boolean, true for the components to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *        redraw continuously as the divider changes position, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *        to wait until the divider position stops changing to redraw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @exception IllegalArgumentException if <code>orientation</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *          is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public JSplitPane(int newOrientation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                      boolean newContinuousLayout) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        this(newOrientation, newContinuousLayout, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Creates a new <code>JSplitPane</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * orientation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * with the specified components that do not do continuous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * redrawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @param newOrientation  <code>JSplitPane.HORIZONTAL_SPLIT</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *                        <code>JSplitPane.VERTICAL_SPLIT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param newLeftComponent the <code>Component</code> that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *          appear on the left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     *          of a horizontally-split pane, or at the top of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *          vertically-split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @param newRightComponent the <code>Component</code> that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *          appear on the right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *          of a horizontally-split pane, or at the bottom of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *          vertically-split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @exception IllegalArgumentException if <code>orientation</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     *          is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    public JSplitPane(int newOrientation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                      Component newLeftComponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                      Component newRightComponent){
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   312
        this(newOrientation,
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   313
            UIManager.getBoolean("SplitPane.continuousLayout"),
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 715
diff changeset
   314
            newLeftComponent, newRightComponent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * Creates a new <code>JSplitPane</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * orientation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * redrawing style, and with the specified components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param newOrientation  <code>JSplitPane.HORIZONTAL_SPLIT</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *                        <code>JSplitPane.VERTICAL_SPLIT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @param newContinuousLayout  a boolean, true for the components to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *        redraw continuously as the divider changes position, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *        to wait until the divider position stops changing to redraw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @param newLeftComponent the <code>Component</code> that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *          appear on the left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *          of a horizontally-split pane, or at the top of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *          vertically-split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @param newRightComponent the <code>Component</code> that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *          appear on the right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *          of a horizontally-split pane, or at the bottom of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *          vertically-split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @exception IllegalArgumentException if <code>orientation</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *          is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public JSplitPane(int newOrientation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                      boolean newContinuousLayout,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                      Component newLeftComponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                      Component newRightComponent){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        dividerLocation = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        setLayout(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        setUIProperty("opaque", Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        orientation = newOrientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            throw new IllegalArgumentException("cannot create JSplitPane, " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                                               "orientation must be one of " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                                               "JSplitPane.HORIZONTAL_SPLIT " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                                               "or JSplitPane.VERTICAL_SPLIT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        continuousLayout = newContinuousLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        if (newLeftComponent != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            setLeftComponent(newLeftComponent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        if (newRightComponent != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            setRightComponent(newRightComponent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Sets the L&F object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @param ui  the <code>SplitPaneUI</code> L&F object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     *  description: The UI object that implements the Component's LookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    public void setUI(SplitPaneUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        if ((SplitPaneUI)this.ui != ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * Returns the <code>SplitPaneUI</code> that is providing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @return the <code>SplitPaneUI</code> object that renders this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *       expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *  description: The L&F object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public SplitPaneUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return (SplitPaneUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * Notification from the <code>UIManager</code> that the L&F has changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Replaces the current UI object with the latest version from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * <code>UIManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        setUI((SplitPaneUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Returns the name of the L&F class that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return the string "SplitPaneUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *       expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *  description: A string that specifies the name of the L&F class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * Sets the size of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * @param newSize an integer giving the size of the divider in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *  description: The size of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public void setDividerSize(int newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        int           oldSize = dividerSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        dividerSizeSet = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        if (oldSize != newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            dividerSize = newSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, newSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * Returns the size of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @return an integer giving the size of the divider in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    public int getDividerSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        return dividerSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Sets the component to the left (or above) the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @param comp the <code>Component</code> to display in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    public void setLeftComponent(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        if (comp == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            if (leftComponent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                remove(leftComponent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                leftComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            add(comp, JSplitPane.LEFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Returns the component to the left (or above) the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @return the <code>Component</code> displayed in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *    preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *  description: The component to the left (or above) the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    public Component getLeftComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        return leftComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * Sets the component above, or to the left of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param comp the <code>Component</code> to display in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     *  description: The component above, or to the left of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public void setTopComponent(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        setLeftComponent(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * Returns the component above, or to the left of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @return the <code>Component</code> displayed in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    public Component getTopComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        return leftComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * Sets the component to the right (or below) the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @param comp the <code>Component</code> to display in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *    preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *  description: The component to the right (or below) the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    public void setRightComponent(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        if (comp == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            if (rightComponent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                remove(rightComponent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                rightComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            add(comp, JSplitPane.RIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * Returns the component to the right (or below) the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @return the <code>Component</code> displayed in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    public Component getRightComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        return rightComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * Sets the component below, or to the right of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @param comp the <code>Component</code> to display in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     *  description: The component below, or to the right of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    public void setBottomComponent(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        setRightComponent(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * Returns the component below, or to the right of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @return the <code>Component</code> displayed in that position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    public Component getBottomComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        return rightComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * Sets the value of the <code>oneTouchExpandable</code> property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * which must be <code>true</code> for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * <code>JSplitPane</code> to provide a UI widget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * on the divider to quickly expand/collapse the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * The default value of this property is <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * Some look and feels might not support one-touch expanding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * they will ignore this property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @param newValue <code>true</code> to specify that the split pane should provide a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *        collapse/expand widget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     *  description: UI widget on the divider to quickly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *               expand/collapse the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @see #isOneTouchExpandable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    public void setOneTouchExpandable(boolean newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        boolean           oldValue = oneTouchExpandable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        oneTouchExpandable = newValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        oneTouchExpandableSet = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * Gets the <code>oneTouchExpandable</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @return the value of the <code>oneTouchExpandable</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * @see #setOneTouchExpandable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    public boolean isOneTouchExpandable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        return oneTouchExpandable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * Sets the last location the divider was at to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * <code>newLastLocation</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @param newLastLocation an integer specifying the last divider location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *        in pixels, from the left (or upper) edge of the pane to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *        left (or upper) edge of the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *  description: The last location the divider was at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    public void setLastDividerLocation(int newLastLocation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        int               oldLocation = lastDividerLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        lastDividerLocation = newLastLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldLocation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                           newLastLocation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * Returns the last location the divider was at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @return an integer specifying the last divider location as a count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     *       of pixels from the left (or upper) edge of the pane to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     *       left (or upper) edge of the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    public int getLastDividerLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        return lastDividerLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Sets the orientation, or how the splitter is divided. The options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * are:<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * <li>JSplitPane.VERTICAL_SPLIT  (above/below orientation of components)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * <li>JSplitPane.HORIZONTAL_SPLIT  (left/right orientation of components)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @param orientation an integer specifying the orientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * @exception IllegalArgumentException if orientation is not one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     *        HORIZONTAL_SPLIT or VERTICAL_SPLIT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     *  description: The orientation, or how the splitter is divided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     *         enum: HORIZONTAL_SPLIT JSplitPane.HORIZONTAL_SPLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *               VERTICAL_SPLIT   JSplitPane.VERTICAL_SPLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    public void setOrientation(int orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        if ((orientation != VERTICAL_SPLIT) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            (orientation != HORIZONTAL_SPLIT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
           throw new IllegalArgumentException("JSplitPane: orientation must " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                                              "be one of " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                                              "JSplitPane.VERTICAL_SPLIT or " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                                              "JSplitPane.HORIZONTAL_SPLIT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        int           oldOrientation = this.orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, orientation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * Returns the orientation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * @return an integer giving the orientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * @see #setOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    public int getOrientation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        return orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Sets the value of the <code>continuousLayout</code> property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * which must be <code>true</code> for the child components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * to be continuously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * redisplayed and laid out during user intervention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * The default value of this property is <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * Some look and feels might not support continuous layout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * they will ignore this property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * @param newContinuousLayout  <code>true</code> if the components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *        should continuously be redrawn as the divider changes position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     *  description: Whether the child components are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     *               continuously redisplayed and laid out during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     *               user intervention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * @see #isContinuousLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    public void setContinuousLayout(boolean newContinuousLayout) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        boolean           oldCD = continuousLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        continuousLayout = newContinuousLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldCD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                           newContinuousLayout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * Gets the <code>continuousLayout</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @return the value of the <code>continuousLayout</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * @see #setContinuousLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    public boolean isContinuousLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        return continuousLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * Specifies how to distribute extra space when the size of the split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * changes. A value of 0, the default,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * indicates the right/bottom component gets all the extra space (the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * left/top component acts fixed), where as a value of 1 specifies the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * left/top component gets all the extra space (the right/bottom component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * acts fixed). Specifically, the left/top component gets (weight * diff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * extra space and the right/bottom component gets (1 - weight) * diff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * extra space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * @param value as described above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * @exception IllegalArgumentException if <code>value</code> is < 0 or > 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     *  description: Specifies how to distribute extra space when the split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     *               resizes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    public void setResizeWeight(double value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        if (value < 0 || value > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            throw new IllegalArgumentException("JSplitPane weight must be between 0 and 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        double         oldWeight = resizeWeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        resizeWeight = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        firePropertyChange(RESIZE_WEIGHT_PROPERTY, oldWeight, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * Returns the number that determines how extra space is distributed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @return how extra space is to be distributed on a resize of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     *         split pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    public double getResizeWeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        return resizeWeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * Lays out the <code>JSplitPane</code> layout based on the preferred size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * of the children components. This will likely result in changing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * the divider location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    public void resetToPreferredSizes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        SplitPaneUI         ui = getUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        if (ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            ui.resetToPreferredSizes(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * Sets the divider location as a percentage of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * <code>JSplitPane</code>'s size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * This method is implemented in terms of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * <code>setDividerLocation(int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * This method immediately changes the size of the split pane based on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * its current size. If the split pane is not correctly realized and on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * screen, this method will have no effect (new divider location will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * become (current size * proportionalLocation) which is 0).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @param proportionalLocation  a double-precision floating point value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     *        that specifies a percentage, from zero (top/left) to 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     *        (bottom/right)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @exception IllegalArgumentException if the specified location is < 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     *            or > 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     *  description: The location of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    public void setDividerLocation(double proportionalLocation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        if (proportionalLocation < 0.0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
           proportionalLocation > 1.0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            throw new IllegalArgumentException("proportional location must " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                                               "be between 0.0 and 1.0.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        if (getOrientation() == VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            setDividerLocation((int)((double)(getHeight() - getDividerSize()) *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                                     proportionalLocation));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            setDividerLocation((int)((double)(getWidth() - getDividerSize()) *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                                     proportionalLocation));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * Sets the location of the divider. This is passed off to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * look and feel implementation, and then listeners are notified. A value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * less than 0 implies the divider should be reset to a value that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * attempts to honor the preferred size of the left/top component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * After notifying the listeners, the last divider location is updated,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * via <code>setLastDividerLocation</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @param location an int specifying a UI-specific value (typically a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     *        pixel count)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     *  description: The location of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    public void setDividerLocation(int location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        int                 oldValue = dividerLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        dividerLocation = location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        // Notify UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        SplitPaneUI         ui = getUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        if (ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            ui.setDividerLocation(this, location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        // Then listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldValue, location);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        // And update the last divider location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        setLastDividerLocation(oldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * Returns the last value passed to <code>setDividerLocation</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * The value returned from this method may differ from the actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * divider location (if <code>setDividerLocation</code> was passed a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * value bigger than the curent size).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * @return an integer specifying the location of the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    public int getDividerLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        return dividerLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * Returns the minimum location of the divider from the look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * @return an integer specifying a UI-specific value for the minimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     *          location (typically a pixel count); or -1 if the UI is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     *          <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     *  description: The minimum location of the divider from the L&F.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    public int getMinimumDividerLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        SplitPaneUI         ui = getUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        if (ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            return ui.getMinimumDividerLocation(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * Returns the maximum location of the divider from the look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * @return an integer specifying a UI-specific value for the maximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     *          location (typically a pixel count); or -1 if the  UI is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     *          <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    public int getMaximumDividerLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        SplitPaneUI         ui = getUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        if (ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            return ui.getMaximumDividerLocation(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * Removes the child component, <code>component</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * pane. Resets the <code>leftComponent</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * <code>rightComponent</code> instance variable, as necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * @param component the <code>Component</code> to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    public void remove(Component component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        if (component == leftComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            leftComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        } else if (component == rightComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            rightComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        super.remove(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        // Update the JSplitPane on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * Removes the <code>Component</code> at the specified index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * Updates the <code>leftComponent</code> and <code>rightComponent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * instance variables as necessary, and then messages super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * @param index an integer specifying the component to remove, where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     *        1 specifies the left/top component and 2 specifies the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     *        bottom/right component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    public void remove(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        Component    comp = getComponent(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        if (comp == leftComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            leftComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        } else if (comp == rightComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            rightComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        super.remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        // Update the JSplitPane on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * Removes all the child components from the split pane. Resets the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * <code>leftComonent</code> and <code>rightComponent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     * instance variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    public void removeAll() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        leftComponent = rightComponent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        super.removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        // Update the JSplitPane on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * Returns true, so that calls to <code>revalidate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * on any descendant of this <code>JSplitPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * will cause a request to be queued that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     * will validate the <code>JSplitPane</code> and all its descendants.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * @return true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * @see JComponent#revalidate
4261
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2658
diff changeset
   950
     * @see java.awt.Container#isValidateRoot
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     *    hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     */
4261
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 2658
diff changeset
   955
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    public boolean isValidateRoot() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * Adds the specified component to this split pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     * If <code>constraints</code> identifies the left/top or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * right/bottom child component, and a component with that identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * was previously added, it will be removed and then <code>comp</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     * will be added in its place. If <code>constraints</code> is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     * one of the known identifiers the layout manager may throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     * <code>IllegalArgumentException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     * The possible constraints objects (Strings) are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * <li>JSplitPane.TOP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * <li>JSplitPane.LEFT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * <li>JSplitPane.BOTTOM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * <li>JSplitPane.RIGHT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * If the <code>constraints</code> object is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * the component is added in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * first available position (left/top if open, else right/bottom).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @param comp        the component to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * @param constraints an <code>Object</code> specifying the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     *                    layout constraints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     *                    (position) for this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * @param index       an integer specifying the index in the container's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     *                    list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * @exception IllegalArgumentException  if the <code>constraints</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     *          object does not match an existing component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * @see java.awt.Container#addImpl(Component, Object, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    protected void addImpl(Component comp, Object constraints, int index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        Component             toRemove;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        if (constraints != null && !(constraints instanceof String)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
            throw new IllegalArgumentException("cannot add to layout: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                                               "constraint must be a string " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                                               "(or null)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        /* If the constraints are null and the left/right component is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
           invalid, add it at the left/right component. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        if (constraints == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            if (getLeftComponent() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                constraints = JSplitPane.LEFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            } else if (getRightComponent() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                constraints = JSplitPane.RIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        /* Find the Component that already exists and remove it. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        if (constraints != null && (constraints.equals(JSplitPane.LEFT) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                                   constraints.equals(JSplitPane.TOP))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            toRemove = getLeftComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
            if (toRemove != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                remove(toRemove);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            leftComponent = comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            index = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        } else if (constraints != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                   (constraints.equals(JSplitPane.RIGHT) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                    constraints.equals(JSplitPane.BOTTOM))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            toRemove = getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            if (toRemove != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                remove(toRemove);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            rightComponent = comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            index = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
        } else if (constraints != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                constraints.equals(JSplitPane.DIVIDER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            index = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        /* LayoutManager should raise for else condition here. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        super.addImpl(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        // Update the JSplitPane on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * Subclassed to message the UI with <code>finishedPaintingChildren</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     * after super has been messaged, as well as painting the border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     * @param g the <code>Graphics</code> context within which to paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    protected void paintChildren(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        super.paintChildren(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        SplitPaneUI        ui = getUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        if (ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            Graphics           tempG = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            ui.finishedPaintingChildren(this, tempG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            tempG.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * See <code>readObject</code> and <code>writeObject</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    void setUIProperty(String propertyName, Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        if (propertyName == "dividerSize") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            if (!dividerSizeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                setDividerSize(((Number)value).intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                dividerSizeSet = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        } else if (propertyName == "oneTouchExpandable") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            if (!oneTouchExpandableSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                setOneTouchExpandable(((Boolean)value).booleanValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                oneTouchExpandableSet = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            super.setUIProperty(propertyName, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * Returns a string representation of this <code>JSplitPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     * @return  a string representation of this <code>JSplitPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        String orientationString = (orientation == HORIZONTAL_SPLIT ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                                    "HORIZONTAL_SPLIT" : "VERTICAL_SPLIT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        String continuousLayoutString = (continuousLayout ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                                         "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        String oneTouchExpandableString = (oneTouchExpandable ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                                           "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        ",continuousLayout=" + continuousLayoutString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
        ",dividerSize=" + dividerSize +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        ",lastDividerLocation=" + lastDividerLocation +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        ",oneTouchExpandable=" + oneTouchExpandableString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        ",orientation=" + orientationString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
    ///////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    // Accessibility support //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    ///////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * Gets the AccessibleContext associated with this JSplitPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     * For split panes, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * AccessibleJSplitPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * A new AccessibleJSplitPane instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
     * @return an AccessibleJSplitPane that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     *         AccessibleContext of this JSplitPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     *       expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     *  description: The AccessibleContext associated with this SplitPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
            accessibleContext = new AccessibleJSplitPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     * <code>JSplitPane</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * Java Accessibility API appropriate to split pane user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    protected class AccessibleJSplitPane extends AccessibleJComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
        implements AccessibleValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
         * Gets the state set of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
         * @return an instance of AccessibleState containing the current state
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
         * of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
            // FIXME: [[[WDW - Should also add BUSY if this implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
            // Adjustable at some point.  If this happens, we probably
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
            // should also add actions.]]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
            if (getOrientation() == VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                states.add(AccessibleState.VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                states.add(AccessibleState.HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
         * Get the AccessibleValue associated with this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
         * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
         * return this object, which is responsible for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
         * AccessibleValue interface on behalf of itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
         * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
         * Gets the accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
         * @return a localized String describing the value of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        public Number getCurrentAccessibleValue() {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  1204
            return Integer.valueOf(getDividerLocation());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
         * Sets the value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
         * @return True if the value was set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        public boolean setCurrentAccessibleValue(Number n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
            // TIGER - 4422535
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            if (n == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
            setDividerLocation(n.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
         * Gets the minimum accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
         * @return The minimum value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        public Number getMinimumAccessibleValue() {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  1229
            return Integer.valueOf(getUI().getMinimumDividerLocation(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                                                        JSplitPane.this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
         * Gets the maximum accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
         * @return The maximum value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        public Number getMaximumAccessibleValue() {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  1240
            return Integer.valueOf(getUI().getMaximumDividerLocation(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
                                                        JSplitPane.this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
         * Gets the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
         * @return an instance of AccessibleRole describing the role of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
         * the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            return AccessibleRole.SPLIT_PANE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
    } // inner class AccessibleJSplitPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
}