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