jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java
author weijun
Thu, 11 Dec 2014 15:19:12 +0800
changeset 28228 be83f404724d
parent 25859 3317bb8137f4
child 28231 b608ffcaed74
permissions -rw-r--r--
8067207: Replace concat String to append in StringBuilder parameters (client) Reviewed-by: serb Contributed-by: Otavio Santana <otaviojava@java.net>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21982
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
package javax.swing.plaf.basic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.swing.border.Border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.swing.DefaultLookup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * Divider used by BasicSplitPaneUI. Subclassers may wish to override
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * paint to do something more interesting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * The border effect is drawn in BasicSplitPaneUI, so if you don't like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * that border, reset it there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * To conditionally drag from certain areas subclass mousePressed and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * call super when you wish the dragging to begin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * 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: 9471
diff changeset
    56
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21982
diff changeset
    62
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public class BasicSplitPaneDivider extends Container
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    implements PropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Width or height of the divider based on orientation
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
    68
     * {@code BasicSplitPaneUI} adds two to this.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected static final int ONE_TOUCH_SIZE = 6;
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
    71
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
    72
    /**
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
    73
     * The offset of the divider.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
    74
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    protected static final int ONE_TOUCH_OFFSET = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Handles mouse dragging message to do the actual dragging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    protected DragController dragger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * UI this instance was created from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    protected BasicSplitPaneUI splitPaneUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Size of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected int dividerSize = 0; // default - SET TO 0???
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Divider that is used for noncontinuous layout mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    protected Component hiddenDivider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * JSplitPane the receiver is contained in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    protected JSplitPane splitPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Handles mouse events from both this class, and the split pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Mouse events are handled for the splitpane since you want to be able
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * to drag when clicking on the border of the divider, which is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * drawn by the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    protected MouseHandler mouseHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Orientation of the JSplitPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    protected int orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * Button for quickly toggling the left component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected JButton leftButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Button for quickly toggling the right component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    protected JButton rightButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /** Border. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private Border border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Is the mouse over the divider?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    private boolean mouseOver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    private int oneTouchSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    private int oneTouchOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * If true the one touch buttons are centered on the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private boolean centerOneTouchButtons;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   143
     * Creates an instance of {@code BasicSplitPaneDivider}. Registers this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * instance for mouse events and mouse dragged events.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   145
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   146
     * @param ui an instance of {@code BasicSplitPaneUI}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public BasicSplitPaneDivider(BasicSplitPaneUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        oneTouchSize = DefaultLookup.getInt(ui.getSplitPane(), ui,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                "SplitPane.oneTouchButtonSize", ONE_TOUCH_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        oneTouchOffset = DefaultLookup.getInt(ui.getSplitPane(), ui,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                "SplitPane.oneTouchButtonOffset", ONE_TOUCH_OFFSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        centerOneTouchButtons = DefaultLookup.getBoolean(ui.getSplitPane(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                 ui, "SplitPane.centerOneTouchButtons", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        setLayout(new DividerLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        setBasicSplitPaneUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        orientation = splitPane.getOrientation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        setCursor((orientation == JSplitPane.HORIZONTAL_SPLIT) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                  Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                  Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        setBackground(UIManager.getColor("SplitPane.background"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
9471
a0139be72f1d 7036669: Simplify revalidating component hierarchy with multiple validate roots
anthony
parents: 5506
diff changeset
   164
    private void revalidateSplitPane() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (splitPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            splitPane.revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   172
     * Sets the {@code SplitPaneUI} that is using the receiver.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   173
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   174
     * @param newUI the new {@code SplitPaneUI}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (splitPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            splitPane.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
           if (mouseHandler != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
               splitPane.removeMouseListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
               splitPane.removeMouseMotionListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
               removeMouseListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
               removeMouseMotionListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
               mouseHandler = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        splitPaneUI = newUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        if (newUI != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            splitPane = newUI.getSplitPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            if (splitPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                if (mouseHandler == null) mouseHandler = new MouseHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                splitPane.addMouseListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                splitPane.addMouseMotionListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                addMouseListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                addMouseMotionListener(mouseHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                splitPane.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                if (splitPane.isOneTouchExpandable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    oneTouchExpandableChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            splitPane = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   209
     * Returns the {@code SplitPaneUI} the receiver is currently in.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   210
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   211
     * @return the {@code SplitPaneUI} the receiver is currently in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public BasicSplitPaneUI getBasicSplitPaneUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return splitPaneUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   219
     * Sets the size of the divider to {@code newSize}. That is
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   220
     * the width if the splitpane is {@code HORIZONTAL_SPLIT}, or
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   221
     * the height of {@code VERTICAL_SPLIT}.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   222
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   223
     * @param newSize a new size
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    public void setDividerSize(int newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        dividerSize = newSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * Returns the size of the divider, that is the width if the splitpane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * is HORIZONTAL_SPLIT, or the height of VERTICAL_SPLIT.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   233
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   234
     * @return the size of the divider
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public int getDividerSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return dividerSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
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
     * Sets the border of this component.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   243
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   244
     * @param border a new border
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public void setBorder(Border border) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        Border         oldBorder = this.border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        this.border = border;
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
     * Returns the border of this component or null if no border is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * currently set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @return the border object for this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see #setBorder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public Border getBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * If a border has been set on this component, returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * border's insets, else calls super.getInsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @return the value of the insets property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @see #setBorder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public Insets getInsets() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        Border    border = getBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        if (border != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            return border.getBorderInsets(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return super.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Sets whether or not the mouse is currently over the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @param mouseOver whether or not the mouse is currently over the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    protected void setMouseOver(boolean mouseOver) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        this.mouseOver = mouseOver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * Returns whether or not the mouse is currently over the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @return whether or not the mouse is currently over the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    public boolean isMouseOver() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        return mouseOver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Returns dividerSize x dividerSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        // Ideally this would return the size from the layout manager,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        // but that could result in the layed out size being different from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        // the dividerSize, which may break developers as well as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        // BasicSplitPaneUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            return new Dimension(getDividerSize(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        return new Dimension(1, getDividerSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Returns dividerSize x dividerSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        return getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * Property change event, presumably from the JSplitPane, will message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * updateOrientation if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (e.getSource() == splitPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            if (e.getPropertyName() == JSplitPane.ORIENTATION_PROPERTY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                orientation = splitPane.getOrientation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                setCursor((orientation == JSplitPane.HORIZONTAL_SPLIT) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                          Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                          Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
9471
a0139be72f1d 7036669: Simplify revalidating component hierarchy with multiple validate roots
anthony
parents: 5506
diff changeset
   334
                revalidateSplitPane();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            else if (e.getPropertyName() == JSplitPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                      ONE_TOUCH_EXPANDABLE_PROPERTY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                oneTouchExpandableChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * Paints the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
      super.paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
      // Paint the border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
      Border   border = getBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      if (border != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
          Dimension     size = getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
          border.paintBorder(this, g, 0, 0, size.width, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * Messaged when the oneTouchExpandable value of the JSplitPane the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * receiver is contained in changes. Will create the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * <code>leftButton</code> and <code>rightButton</code> if they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * are null. invalidates the receiver as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    protected void oneTouchExpandableChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (!DefaultLookup.getBoolean(splitPane, splitPaneUI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                           "SplitPane.supportsOneTouchButtons", true)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            // Look and feel doesn't want to support one touch buttons, bail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        if (splitPane.isOneTouchExpandable() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            leftButton == null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            rightButton == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            /* Create the left button and add an action listener to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
               expand/collapse it. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            leftButton = createLeftOneTouchButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            if (leftButton != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                leftButton.addActionListener(new OneTouchActionHandler(true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            /* Create the right button and add an action listener to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
               expand/collapse it. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            rightButton = createRightOneTouchButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            if (rightButton != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                rightButton.addActionListener(new OneTouchActionHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    (false));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            if (leftButton != null && rightButton != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                add(leftButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                add(rightButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        }
9471
a0139be72f1d 7036669: Simplify revalidating component hierarchy with multiple validate roots
anthony
parents: 5506
diff changeset
   395
        revalidateSplitPane();
2
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
    /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   400
     * Creates and return an instance of {@code JButton} that can be used to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * collapse the left component in the split pane.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   402
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   403
     * @return an instance of {@code JButton}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    protected JButton createLeftOneTouchButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        JButton b = new JButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            public void setBorder(Border b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                if (splitPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                    int[]   xs = new int[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                    int[]   ys = new int[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                    int     blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                    // Fill the background first ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                    g.setColor(this.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                    g.fillRect(0, 0, this.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                               this.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                    // ... then draw the arrow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                    g.setColor(Color.black);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                    if (orientation == JSplitPane.VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                        blockSize = Math.min(getHeight(), oneTouchSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                        xs[0] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                        xs[1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                        xs[2] = blockSize << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                        ys[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                        ys[1] = ys[2] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                        g.drawPolygon(xs, ys, 3); // Little trick to make the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                                  // arrows of equal size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                        blockSize = Math.min(getWidth(), oneTouchSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                        xs[0] = xs[2] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                        xs[1] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                        ys[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        ys[1] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                        ys[2] = blockSize << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    g.fillPolygon(xs, ys, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            // Don't want the button to participate in focus traversable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        b.setFocusPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        b.setBorderPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        b.setRequestFocusEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return b;
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
    /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   458
     * Creates and return an instance of {@code JButton} that can be used to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * collapse the right component in the split pane.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   460
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   461
     * @return an instance of {@code JButton}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    protected JButton createRightOneTouchButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        JButton b = new JButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            public void setBorder(Border border) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                if (splitPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                    int[]          xs = new int[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    int[]          ys = new int[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                    int            blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                    // Fill the background first ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                    g.setColor(this.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                    g.fillRect(0, 0, this.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                               this.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    // ... then draw the arrow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    if (orientation == JSplitPane.VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                        blockSize = Math.min(getHeight(), oneTouchSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                        xs[0] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                        xs[1] = blockSize << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                        xs[2] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                        ys[0] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                        ys[1] = ys[2] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                        blockSize = Math.min(getWidth(), oneTouchSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                        xs[0] = xs[2] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                        xs[1] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                        ys[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                        ys[1] = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                        ys[2] = blockSize << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                    g.setColor(Color.black);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                    g.fillPolygon(xs, ys, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            // Don't want the button to participate in focus traversable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        b.setFocusPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        b.setBorderPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        b.setRequestFocusEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * Message to prepare for dragging. This messages the BasicSplitPaneUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * with startDragging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    protected void prepareForDragging() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        splitPaneUI.startDragging();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * Messages the BasicSplitPaneUI with dragDividerTo that this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * is contained in.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   525
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   526
     * @param location a location
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    protected void dragDividerTo(int location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        splitPaneUI.dragDividerTo(location);
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
     * Messages the BasicSplitPaneUI with finishDraggingTo that this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * is contained in.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   536
     *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   537
     * @param location a location
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    protected void finishDraggingTo(int location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        splitPaneUI.finishDraggingTo(location);
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * MouseHandler is responsible for converting mouse events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * (released, dragged...) into the appropriate DragController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * methods.
21982
fd6e5fe509df 8029264: [doclint] more doclint and tidy cleanup
yan
parents: 20458
diff changeset
   548
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    protected class MouseHandler extends MouseAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            implements MouseMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
         * Starts the dragging session by creating the appropriate instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
         * of DragController.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        public void mousePressed(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            if ((e.getSource() == BasicSplitPaneDivider.this ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                 e.getSource() == splitPane) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                dragger == null &&splitPane.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                Component            newHiddenDivider = splitPaneUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                                     getNonContinuousLayoutDivider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                if (hiddenDivider != newHiddenDivider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                    if (hiddenDivider != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                        hiddenDivider.removeMouseListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        hiddenDivider.removeMouseMotionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                    hiddenDivider = newHiddenDivider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    if (hiddenDivider != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                        hiddenDivider.addMouseMotionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                        hiddenDivider.addMouseListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                if (splitPane.getLeftComponent() != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                    splitPane.getRightComponent() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                    if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                        dragger = new DragController(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                        dragger = new VerticalDragController(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                    if (!dragger.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                        dragger = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                        prepareForDragging();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                        dragger.continueDrag(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
         * If dragger is not null it is messaged with completeDrag.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        public void mouseReleased(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            if (dragger != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                if (e.getSource() == splitPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                    dragger.completeDrag(e.getX(), e.getY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                else if (e.getSource() == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                    Point   ourLoc = getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                    dragger.completeDrag(e.getX() + ourLoc.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                                         e.getY() + ourLoc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                else if (e.getSource() == hiddenDivider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                    Point   hDividerLoc = hiddenDivider.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    int     ourX = e.getX() + hDividerLoc.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    int     ourY = e.getY() + hDividerLoc.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                    dragger.completeDrag(ourX, ourY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                dragger = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        // MouseMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
         * If dragger is not null it is messaged with continueDrag.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        public void mouseDragged(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            if (dragger != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                if (e.getSource() == splitPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                    dragger.continueDrag(e.getX(), e.getY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                else if (e.getSource() == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                    Point   ourLoc = getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                    dragger.continueDrag(e.getX() + ourLoc.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                                         e.getY() + ourLoc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                else if (e.getSource() == hiddenDivider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                    Point   hDividerLoc = hiddenDivider.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                    int     ourX = e.getX() + hDividerLoc.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                    int     ourY = e.getY() + hDividerLoc.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                    dragger.continueDrag(ourX, ourY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            }
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
         *  Resets the cursor based on the orientation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        public void mouseMoved(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
         * Invoked when the mouse enters a component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
         * @param e MouseEvent describing the details of the enter event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
         * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        public void mouseEntered(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            if (e.getSource() == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                setMouseOver(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
         * Invoked when the mouse exits a component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
         * @param e MouseEvent describing the details of the exit event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
         * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        public void mouseExited(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            if (e.getSource() == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                setMouseOver(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * Handles the events during a dragging session for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * HORIZONTAL_SPLIT oriented split pane. This continually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * messages <code>dragDividerTo</code> and then when done messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * <code>finishDraggingTo</code>. When an instance is created it should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * messaged with <code>isValid</code> to insure that dragging can happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * (dragging won't be allowed if the two views can not be resized).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * 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: 9471
diff changeset
   698
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21982
diff changeset
   702
    @SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    protected class DragController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
         * Initial location of the divider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        int initialX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
         * Maximum and minimum positions to drag to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        int maxX, minX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
         * Initial location the mouse down happened at.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   720
        /**
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   721
         * Constructs a new instance of {@code DragController}.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   722
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   723
         * @param e a mouse event
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   724
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        protected DragController(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            JSplitPane  splitPane = splitPaneUI.getSplitPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            Component   leftC = splitPane.getLeftComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            Component   rightC = splitPane.getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            initialX = getLocation().x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            if (e.getSource() == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                offset = e.getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            else { // splitPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                offset = e.getX() - initialX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            if (leftC == null || rightC == null || offset < -1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                offset >= getSize().width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                // Don't allow dragging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                maxX = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                Insets      insets = splitPane.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                if (leftC.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                    minX = leftC.getMinimumSize().width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                    if (insets != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                        minX += insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                    minX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                if (rightC.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                    int right = (insets != null) ? insets.right : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                    maxX = Math.max(0, splitPane.getSize().width -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                                    (getSize().width + right) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                                    rightC.getMinimumSize().width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                    int right = (insets != null) ? insets.right : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                    maxX = Math.max(0, splitPane.getSize().width -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                                    (getSize().width + right));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                if (maxX < minX) minX = maxX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        /**
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   771
         * Returns {@code true} if the dragging session is valid.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   772
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   773
         * @return {@code true} if the dragging session is valid
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        protected boolean isValid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            return (maxX > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
         * Returns the new position to put the divider at based on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
         * the passed in MouseEvent.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   783
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   784
         * @param e a mouse event
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   785
         * @return the new position
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        protected int positionForMouseEvent(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            int newX = (e.getSource() == BasicSplitPaneDivider.this) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                        (e.getX() + getLocation().x) : e.getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            newX = Math.min(maxX, Math.max(minX, newX - offset));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            return newX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
         * Returns the x argument, since this is used for horizontal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
         * splits.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   799
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   800
         * @param x an X coordinate
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   801
         * @param y an Y coordinate
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   802
         * @return the X argument
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        protected int getNeededLocation(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            int newX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            newX = Math.min(maxX, Math.max(minX, x - offset));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            return newX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   811
        /**
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   812
         * Messages dragDividerTo with the new location for the mouse
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   813
         * event.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   814
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   815
         * @param newX an X coordinate
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   816
         * @param newY an Y coordinate
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   817
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        protected void continueDrag(int newX, int newY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            dragDividerTo(getNeededLocation(newX, newY));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
         * Messages dragDividerTo with the new location for the mouse
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
         * event.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   826
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   827
         * @param e a mouse event
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        protected void continueDrag(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
            dragDividerTo(positionForMouseEvent(e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   833
        /**
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   834
         * Messages finishDraggingTo with the new location for the mouse
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   835
         * event.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   836
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   837
         * @param x an X coordinate
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   838
         * @param y an Y coordinate
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   839
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        protected void completeDrag(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            finishDraggingTo(getNeededLocation(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
         * Messages finishDraggingTo with the new location for the mouse
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
         * event.
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   848
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   849
         * @param e a mouse event
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        protected void completeDrag(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            finishDraggingTo(positionForMouseEvent(e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    } // End of BasicSplitPaneDivider.DragController
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
     * Handles the events during a dragging session for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * VERTICAL_SPLIT oriented split pane. This continually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * messages <code>dragDividerTo</code> and then when done messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * <code>finishDraggingTo</code>. When an instance is created it should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * messaged with <code>isValid</code> to insure that dragging can happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     * (dragging won't be allowed if the two views can not be resized).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    protected class VerticalDragController extends DragController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        /* DragControllers ivars are now in terms of y, not x. */
25763
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   868
        /**
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   869
         * Constructs a new instance of {@code VerticalDragController}.
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   870
         *
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   871
         * @param e a mouse event
51d1f910f68d 8049704: Fix doclint warnings from javax.swing.plaf.basic package, 2 of 7
aeremeev
parents: 22574
diff changeset
   872
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        protected VerticalDragController(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            super(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            JSplitPane splitPane = splitPaneUI.getSplitPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            Component  leftC = splitPane.getLeftComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            Component  rightC = splitPane.getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            initialX = getLocation().y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            if (e.getSource() == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                offset = e.getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                offset = e.getY() - initialX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            if (leftC == null || rightC == null || offset < -1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                offset > getSize().height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                // Don't allow dragging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                maxX = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                Insets     insets = splitPane.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                if (leftC.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                    minX = leftC.getMinimumSize().height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                    if (insets != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                        minX += insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                    minX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                if (rightC.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                    int    bottom = (insets != null) ? insets.bottom : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                    maxX = Math.max(0, splitPane.getSize().height -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                                    (getSize().height + bottom) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                                    rightC.getMinimumSize().height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                    int    bottom = (insets != null) ? insets.bottom : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                    maxX = Math.max(0, splitPane.getSize().height -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                                    (getSize().height + bottom));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                if (maxX < minX) minX = maxX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
         * Returns the y argument, since this is used for vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
         * splits.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        protected int getNeededLocation(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            int newY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            newY = Math.min(maxX, Math.max(minX, y - offset));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            return newY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
         * Returns the new position to put the divider at based on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
         * the passed in MouseEvent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        protected int positionForMouseEvent(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            int newY = (e.getSource() == BasicSplitPaneDivider.this) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                        (e.getY() + getLocation().y) : e.getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            newY = Math.min(maxX, Math.max(minX, newY - offset));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            return newY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    } // End of BasicSplitPaneDividier.VerticalDragController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * Used to layout a <code>BasicSplitPaneDivider</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * Layout for the divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * involves appropriately moving the left/right buttons around.
21982
fd6e5fe509df 8029264: [doclint] more doclint and tidy cleanup
yan
parents: 20458
diff changeset
   952
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    protected class DividerLayout implements LayoutManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        public void layoutContainer(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            if (leftButton != null && rightButton != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                c == BasicSplitPaneDivider.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                if (splitPane.isOneTouchExpandable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                    Insets insets = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                    if (orientation == JSplitPane.VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                        int extraX = (insets != null) ? insets.left : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                        int blockSize = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                        if (insets != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                            blockSize -= (insets.top + insets.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                            blockSize = Math.max(blockSize, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                        blockSize = Math.min(blockSize, oneTouchSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                        int y = (c.getSize().height - blockSize) / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                        if (!centerOneTouchButtons) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                            y = (insets != null) ? insets.top : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                            extraX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                        leftButton.setBounds(extraX + oneTouchOffset, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                                             blockSize * 2, blockSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                        rightButton.setBounds(extraX + oneTouchOffset +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                                              oneTouchSize * 2, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                                              blockSize * 2, blockSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                        int extraY = (insets != null) ? insets.top : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                        int blockSize = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                        if (insets != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                            blockSize -= (insets.left + insets.right);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                            blockSize = Math.max(blockSize, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                        blockSize = Math.min(blockSize, oneTouchSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                        int x = (c.getSize().width - blockSize) / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                        if (!centerOneTouchButtons) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                            x = (insets != null) ? insets.left : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                            extraY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                        leftButton.setBounds(x, extraY + oneTouchOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                                             blockSize, blockSize * 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                        rightButton.setBounds(x, extraY + oneTouchOffset +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                                              oneTouchSize * 2, blockSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                                              blockSize * 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                    leftButton.setBounds(-5, -5, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                    rightButton.setBounds(-5, -5, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            // NOTE: This isn't really used, refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            // BasicSplitPaneDivider.getPreferredSize for the reason.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            // I leave it in hopes of having this used at some point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            if (c != BasicSplitPaneDivider.this || splitPane == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                return new Dimension(0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            Dimension buttonMinSize = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            if (splitPane.isOneTouchExpandable() && leftButton != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                buttonMinSize = leftButton.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            Insets insets = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            int width = getDividerSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            int height = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            if (orientation == JSplitPane.VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                if (buttonMinSize != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                    int size = buttonMinSize.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
                    if (insets != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                        size += insets.top + insets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                    height = Math.max(height, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                width = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                if (buttonMinSize != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                    int size = buttonMinSize.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                    if (insets != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                        size += insets.left + insets.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                    width = Math.max(width, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            return new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        public Dimension preferredLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            return minimumLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        public void removeLayoutComponent(Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        public void addLayoutComponent(String string, Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
    } // End of class BasicSplitPaneDivider.DividerLayout
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
     * Listeners installed on the one touch expandable buttons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    private class OneTouchActionHandler implements ActionListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        /** True indicates the resize should go the minimum (top or left)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
         * vs false which indicates the resize should go to the maximum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
        private boolean toMinimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
        OneTouchActionHandler(boolean toMinimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            this.toMinimum = toMinimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            Insets  insets = splitPane.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            int     lastLoc = splitPane.getLastDividerLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
            int     currentLoc = splitPaneUI.getDividerLocation(splitPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            int     newLoc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            // We use the location from the UI directly, as the location the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            // JSplitPane itself maintains is not necessarly correct.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            if (toMinimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                if (orientation == JSplitPane.VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                    if (currentLoc >= (splitPane.getHeight() -
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                                       insets.bottom - getHeight())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                        int maxLoc = splitPane.getMaximumDividerLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                        newLoc = Math.min(lastLoc, maxLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                        splitPaneUI.setKeepHidden(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                        newLoc = insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                        splitPaneUI.setKeepHidden(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                    if (currentLoc >= (splitPane.getWidth() -
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                                       insets.right - getWidth())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                        int maxLoc = splitPane.getMaximumDividerLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                        newLoc = Math.min(lastLoc, maxLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                        splitPaneUI.setKeepHidden(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                        newLoc = insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                        splitPaneUI.setKeepHidden(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                if (orientation == JSplitPane.VERTICAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                    if (currentLoc == insets.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
                        int maxLoc = splitPane.getMaximumDividerLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                        newLoc = Math.min(lastLoc, maxLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                        splitPaneUI.setKeepHidden(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                        newLoc = splitPane.getHeight() - getHeight() -
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                                 insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                        splitPaneUI.setKeepHidden(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                    if (currentLoc == insets.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                        int maxLoc = splitPane.getMaximumDividerLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                        newLoc = Math.min(lastLoc, maxLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                        splitPaneUI.setKeepHidden(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
                        newLoc = splitPane.getWidth() - getWidth() -
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                                 insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                        splitPaneUI.setKeepHidden(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            if (currentLoc != newLoc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                splitPane.setDividerLocation(newLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                // We do this in case the dividers notion of the location
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                // differs from the real location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                splitPane.setLastDividerLocation(currentLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    } // End of class BasicSplitPaneDivider.LeftActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
}