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