1 /*
2 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42
43 /**
44 * Divider used by BasicSplitPaneUI. Subclassers may wish to override
45 * paint to do something more interesting.
46 * The border effect is drawn in BasicSplitPaneUI, so if you don't like
47 * that border, reset it there.
48 * To conditionally drag from certain areas subclass mousePressed and
49 * call super when you wish the dragging to begin.
50 * <p>
51 * <strong>Warning:</strong>
52 * Serialized objects of this class will not be compatible with
53 * future Swing releases. The current serialization support is
54 * appropriate for short term storage or RMI between applications running
55 * the same version of Swing. As of 1.4, support for long term storage
56 * of all JavaBeans™
57 * has been added to the <code>java.beans</code> package.
58 * Please see {@link java.beans.XMLEncoder}.
59 *
60 * @author Scott Violet
61 */
62 public class BasicSplitPaneDivider extends Container
63 implements PropertyChangeListener
64 {
65 /**
66 * Width or height of the divider based on orientation
67 * BasicSplitPaneUI adds two to this.
68 */
69 protected static final int ONE_TOUCH_SIZE = 6;
70 protected static final int ONE_TOUCH_OFFSET = 2;
71
72 /**
73 * Handles mouse dragging message to do the actual dragging.
74 */
75 protected DragController dragger;
76
77 /**
78 * UI this instance was created from.
79 */
80 protected BasicSplitPaneUI splitPaneUI;
81
658 }
659
660
661 /**
662 * Handles the events during a dragging session for a
663 * HORIZONTAL_SPLIT oriented split pane. This continually
664 * messages <code>dragDividerTo</code> and then when done messages
665 * <code>finishDraggingTo</code>. When an instance is created it should be
666 * messaged with <code>isValid</code> to insure that dragging can happen
667 * (dragging won't be allowed if the two views can not be resized).
668 * <p>
669 * <strong>Warning:</strong>
670 * Serialized objects of this class will not be compatible with
671 * future Swing releases. The current serialization support is
672 * appropriate for short term storage or RMI between applications running
673 * the same version of Swing. As of 1.4, support for long term storage
674 * of all JavaBeans™
675 * has been added to the <code>java.beans</code> package.
676 * Please see {@link java.beans.XMLEncoder}.
677 */
678 protected class DragController
679 {
680 /**
681 * Initial location of the divider.
682 */
683 int initialX;
684
685 /**
686 * Maximum and minimum positions to drag to.
687 */
688 int maxX, minX;
689
690 /**
691 * Initial location the mouse down happened at.
692 */
693 int offset;
694
695
696 protected DragController(MouseEvent e) {
697 JSplitPane splitPane = splitPaneUI.getSplitPane();
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42
43 /**
44 * Divider used by BasicSplitPaneUI. Subclassers may wish to override
45 * paint to do something more interesting.
46 * The border effect is drawn in BasicSplitPaneUI, so if you don't like
47 * that border, reset it there.
48 * To conditionally drag from certain areas subclass mousePressed and
49 * call super when you wish the dragging to begin.
50 * <p>
51 * <strong>Warning:</strong>
52 * Serialized objects of this class will not be compatible with
53 * future Swing releases. The current serialization support is
54 * appropriate for short term storage or RMI between applications running
55 * the same version of Swing. As of 1.4, support for long term storage
56 * of all JavaBeans™
57 * has been added to the <code>java.beans</code> package.
58 * Please see {@link java.beans.XMLEncoder}.
59 *
60 * @author Scott Violet
61 */
62 @SuppressWarnings("serial") // Same-version serialization only
63 public class BasicSplitPaneDivider extends Container
64 implements PropertyChangeListener
65 {
66 /**
67 * Width or height of the divider based on orientation
68 * BasicSplitPaneUI adds two to this.
69 */
70 protected static final int ONE_TOUCH_SIZE = 6;
71 protected static final int ONE_TOUCH_OFFSET = 2;
72
73 /**
74 * Handles mouse dragging message to do the actual dragging.
75 */
76 protected DragController dragger;
77
78 /**
79 * UI this instance was created from.
80 */
81 protected BasicSplitPaneUI splitPaneUI;
82
659 }
660
661
662 /**
663 * Handles the events during a dragging session for a
664 * HORIZONTAL_SPLIT oriented split pane. This continually
665 * messages <code>dragDividerTo</code> and then when done messages
666 * <code>finishDraggingTo</code>. When an instance is created it should be
667 * messaged with <code>isValid</code> to insure that dragging can happen
668 * (dragging won't be allowed if the two views can not be resized).
669 * <p>
670 * <strong>Warning:</strong>
671 * Serialized objects of this class will not be compatible with
672 * future Swing releases. The current serialization support is
673 * appropriate for short term storage or RMI between applications running
674 * the same version of Swing. As of 1.4, support for long term storage
675 * of all JavaBeans™
676 * has been added to the <code>java.beans</code> package.
677 * Please see {@link java.beans.XMLEncoder}.
678 */
679 @SuppressWarnings("serial") // Same-version serialization only
680 protected class DragController
681 {
682 /**
683 * Initial location of the divider.
684 */
685 int initialX;
686
687 /**
688 * Maximum and minimum positions to drag to.
689 */
690 int maxX, minX;
691
692 /**
693 * Initial location the mouse down happened at.
694 */
695 int offset;
696
697
698 protected DragController(MouseEvent e) {
699 JSplitPane splitPane = splitPaneUI.getSplitPane();
|