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