/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.accessibility.*;
/**
* <code>JSplitPane</code> is used to divide two (and only two)
* <code>Component</code>s. The two <code>Component</code>s
* are graphically divided based on the look and feel
* implementation, and the two <code>Component</code>s can then be
* interactively resized by the user.
* Information on using <code>JSplitPane</code> is in
* <a
href="http://java.sun.com/docs/books/tutorial/uiswing/components/splitpane.html">How to Use Split Panes</a> in
* <em>The Java Tutorial</em>.
* <p>
* The two <code>Component</code>s in a split pane can be aligned
* left to right using
* <code>JSplitPane.HORIZONTAL_SPLIT</code>, or top to bottom using
* <code>JSplitPane.VERTICAL_SPLIT</code>.
* The preferred way to change the size of the <code>Component</code>s
* is to invoke
* <code>setDividerLocation</code> where <code>location</code> is either
* the new x or y position, depending on the orientation of the
* <code>JSplitPane</code>.
* <p>
* To resize the <code>Component</code>s to their preferred sizes invoke
* <code>resetToPreferredSizes</code>.
* <p>
* When the user is resizing the <code>Component</code>s the minimum
* size of the <code>Components</code> is used to determine the
* can be set to. If the minimum size of the two
* components is greater than the size of the split pane the divider
* will not allow you to resize it. To alter the minimum size of a
* <code>JComponent</code>, see {@link JComponent#setMinimumSize}.
* <p>
* When the user resizes the split pane the new space is distributed between
* the two components based on the <code>resizeWeight</code> property.
* A value of 0,
* <p>
* <strong>Warning:</strong> Swing is not thread safe. For more
* information see <a
* href="package-summary.html#threading">Swing's Threading
* Policy</a>.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see #setDividerLocation
* @see #resetToPreferredSizes
*
* @author Scott Violet
*/
{
/**
* @see #getUIClassID
* @see #readObject
*/
/**
* Vertical split indicates the <code>Component</code>s are
* split along the y axis. For example the two
* <code>Component</code>s will be split one on top of the other.
*/
/**
* Horizontal split indicates the <code>Component</code>s are
* split along the x axis. For example the two
* <code>Component</code>s will be split one to the left of the
* other.
*/
/**
* Used to add a <code>Component</code> to the left of the other
* <code>Component</code>.
*/
/**
* Used to add a <code>Component</code> to the right of the other
* <code>Component</code>.
*/
/**
* Used to add a <code>Component</code> above the other
* <code>Component</code>.
*/
/**
* Used to add a <code>Component</code> below the other
* <code>Component</code>.
*/
/**
* Used to add a <code>Component</code> that will represent the divider.
*/
/**
* Bound property name for orientation (horizontal or vertical).
*/
/**
* Bound property name for continuousLayout.
*/
/**
* Bound property name for border.
*/
/**
* Bound property for oneTouchExpandable.
*/
"oneTouchExpandable";
/**
* Bound property for lastLocation.
*/
"lastDividerLocation";
/**
* Bound property for the dividerLocation.
* @since 1.3
*/
/**
* Bound property for weight.
* @since 1.3
*/
/**
* How the views are split.
*/
protected int orientation;
/**
* Whether or not the views are continuously redisplayed while
* resizing.
*/
protected boolean continuousLayout;
/**
* The left or top component.
*/
/**
* The right or bottom component.
*/
/**
* Size of the divider.
*/
protected int dividerSize;
private boolean dividerSizeSet = false;
/**
* split pane?
*/
protected boolean oneTouchExpandable;
private boolean oneTouchExpandableSet;
/**
* Previous location of the split pane.
*/
protected int lastDividerLocation;
/**
* How to distribute extra space.
*/
private double resizeWeight;
/**
* Location of the divider, at least the value that was set, the UI may
* have a different value.
*/
private int dividerLocation;
/**
* Creates a new <code>JSplitPane</code> configured to arrange the child
* components side-by-side horizontally, using two buttons for the components.
*/
public JSplitPane() {
this(JSplitPane.HORIZONTAL_SPLIT,
}
/**
* Creates a new <code>JSplitPane</code> configured with the
* specified orientation.
*
* @param newOrientation <code>JSplitPane.HORIZONTAL_SPLIT</code> or
* <code>JSplitPane.VERTICAL_SPLIT</code>
* @exception IllegalArgumentException if <code>orientation</code>
* is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT.
*/
@ConstructorProperties({"orientation"})
this(newOrientation,
}
/**
* Creates a new <code>JSplitPane</code> with the specified
* orientation and redrawing style.
*
* @param newOrientation <code>JSplitPane.HORIZONTAL_SPLIT</code> or
* <code>JSplitPane.VERTICAL_SPLIT</code>
* @param newContinuousLayout a boolean, true for the components to
* redraw continuously as the divider changes position, false
* to wait until the divider position stops changing to redraw
* @exception IllegalArgumentException if <code>orientation</code>
* is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
*/
boolean newContinuousLayout) {
}
/**
* Creates a new <code>JSplitPane</code> with the specified
* orientation and the specified components.
*
* @param newOrientation <code>JSplitPane.HORIZONTAL_SPLIT</code> or
* <code>JSplitPane.VERTICAL_SPLIT</code>
* @param newLeftComponent the <code>Component</code> that will
* appear on the left
* of a horizontally-split pane, or at the top of a
* vertically-split pane
* @param newRightComponent the <code>Component</code> that will
* appear on the right
* of a horizontally-split pane, or at the bottom of a
* vertically-split pane
* @exception IllegalArgumentException if <code>orientation</code>
* is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT
*/
this(newOrientation,
}
/**
* Creates a new <code>JSplitPane</code> with the specified
* orientation and
* redrawing style, and with the specified components.
*
* @param newOrientation <code>JSplitPane.HORIZONTAL_SPLIT</code> or
* <code>JSplitPane.VERTICAL_SPLIT</code>
* @param newContinuousLayout a boolean, true for the components to
* redraw continuously as the divider changes position, false
* to wait until the divider position stops changing to redraw
* @param newLeftComponent the <code>Component</code> that will
* appear on the left
* of a horizontally-split pane, or at the top of a
* vertically-split pane
* @param newRightComponent the <code>Component</code> that will
* appear on the right
* of a horizontally-split pane, or at the bottom of a
* vertically-split pane
* @exception IllegalArgumentException if <code>orientation</code>
* is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
*/
boolean newContinuousLayout,
super();
dividerLocation = -1;
throw new IllegalArgumentException("cannot create JSplitPane, " +
"orientation must be one of " +
"JSplitPane.HORIZONTAL_SPLIT " +
"or JSplitPane.VERTICAL_SPLIT");
if (newLeftComponent != null)
if (newRightComponent != null)
updateUI();
}
/**
* Sets the L&F object that renders this component.
*
* @param ui the <code>SplitPaneUI</code> L&F object
* @see UIDefaults#getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
* description: The UI object that implements the Component's LookAndFeel.
*/
revalidate();
}
}
/**
* Returns the <code>SplitPaneUI</code> that is providing the
* current look and feel.
*
* @return the <code>SplitPaneUI</code> object that renders this component
* @beaninfo
* expert: true
* description: The L&F object that renders this component.
*/
return (SplitPaneUI)ui;
}
/**
* Notification from the <code>UIManager</code> that the L&F has changed.
* Replaces the current UI object with the latest version from the
* <code>UIManager</code>.
*
* @see JComponent#updateUI
*/
public void updateUI() {
revalidate();
}
/**
* Returns the name of the L&F class that renders this component.
*
* @return the string "SplitPaneUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
* @beaninfo
* expert: true
* description: A string that specifies the name of the L&F class.
*/
return uiClassID;
}
/**
* Sets the size of the divider.
*
* @param newSize an integer giving the size of the divider in pixels
* @beaninfo
* bound: true
* description: The size of the divider.
*/
int oldSize = dividerSize;
dividerSizeSet = true;
}
}
/**
* Returns the size of the divider.
*
* @return an integer giving the size of the divider in pixels
*/
public int getDividerSize() {
return dividerSize;
}
/**
* Sets the component to the left (or above) the divider.
*
* @param comp the <code>Component</code> to display in that position
*/
if (leftComponent != null) {
}
} else {
}
}
/**
* Returns the component to the left (or above) the divider.
*
* @return the <code>Component</code> displayed in that position
* @beaninfo
* preferred: true
* description: The component to the left (or above) the divider.
*/
return leftComponent;
}
/**
* Sets the component above, or to the left of the divider.
*
* @param comp the <code>Component</code> to display in that position
* @beaninfo
* description: The component above, or to the left of the divider.
*/
}
/**
* Returns the component above, or to the left of the divider.
*
* @return the <code>Component</code> displayed in that position
*/
return leftComponent;
}
/**
* Sets the component to the right (or below) the divider.
*
* @param comp the <code>Component</code> to display in that position
* @beaninfo
* preferred: true
* description: The component to the right (or below) the divider.
*/
if (rightComponent != null) {
}
} else {
}
}
/**
* Returns the component to the right (or below) the divider.
*
* @return the <code>Component</code> displayed in that position
*/
return rightComponent;
}
/**
* Sets the component below, or to the right of the divider.
*
* @param comp the <code>Component</code> to display in that position
* @beaninfo
* description: The component below, or to the right of the divider.
*/
}
/**
* Returns the component below, or to the right of the divider.
*
* @return the <code>Component</code> displayed in that position
*/
return rightComponent;
}
/**
* Sets the value of the <code>oneTouchExpandable</code> property,
* which must be <code>true</code> for the
* <code>JSplitPane</code> to provide a UI widget
* The default value of this property is <code>false</code>.
* Some look and feels might not support one-touch expanding;
* they will ignore this property.
*
* @param newValue <code>true</code> to specify that the split pane should provide a
* @beaninfo
* bound: true
* description: UI widget on the divider to quickly
*
* @see #isOneTouchExpandable
*/
boolean oldValue = oneTouchExpandable;
oneTouchExpandableSet = true;
repaint();
}
/**
* Gets the <code>oneTouchExpandable</code> property.
*
* @return the value of the <code>oneTouchExpandable</code> property
* @see #setOneTouchExpandable
*/
public boolean isOneTouchExpandable() {
return oneTouchExpandable;
}
/**
* Sets the last location the divider was at to
* <code>newLastLocation</code>.
*
* @param newLastLocation an integer specifying the last divider location
* in pixels, from the left (or upper) edge of the pane to the
* left (or upper) edge of the divider
* @beaninfo
* bound: true
* description: The last location the divider was at.
*/
int oldLocation = lastDividerLocation;
}
/**
* Returns the last location the divider was at.
*
* @return an integer specifying the last divider location as a count
* of pixels from the left (or upper) edge of the pane to the
* left (or upper) edge of the divider
*/
public int getLastDividerLocation() {
return lastDividerLocation;
}
/**
* Sets the orientation, or how the splitter is divided. The options
* are:<ul>
* </ul>
*
* @param orientation an integer specifying the orientation
* @exception IllegalArgumentException if orientation is not one of:
* HORIZONTAL_SPLIT or VERTICAL_SPLIT.
* @beaninfo
* bound: true
* description: The orientation, or how the splitter is divided.
* enum: HORIZONTAL_SPLIT JSplitPane.HORIZONTAL_SPLIT
* VERTICAL_SPLIT JSplitPane.VERTICAL_SPLIT
*/
if ((orientation != VERTICAL_SPLIT) &&
(orientation != HORIZONTAL_SPLIT)) {
throw new IllegalArgumentException("JSplitPane: orientation must " +
"be one of " +
"JSplitPane.VERTICAL_SPLIT or " +
"JSplitPane.HORIZONTAL_SPLIT");
}
int oldOrientation = this.orientation;
this.orientation = orientation;
}
/**
* Returns the orientation.
*
* @return an integer giving the orientation
* @see #setOrientation
*/
public int getOrientation() {
return orientation;
}
/**
* Sets the value of the <code>continuousLayout</code> property,
* which must be <code>true</code> for the child components
* to be continuously
* redisplayed and laid out during user intervention.
* The default value of this property is look and feel dependent.
* Some look and feels might not support continuous layout;
* they will ignore this property.
*
* @param newContinuousLayout <code>true</code> if the components
* should continuously be redrawn as the divider changes position
* @beaninfo
* bound: true
* description: Whether the child components are
* continuously redisplayed and laid out during
* user intervention.
* @see #isContinuousLayout
*/
boolean oldCD = continuousLayout;
}
/**
* Gets the <code>continuousLayout</code> property.
*
* @return the value of the <code>continuousLayout</code> property
* @see #setContinuousLayout
*/
public boolean isContinuousLayout() {
return continuousLayout;
}
/**
* Specifies how to distribute extra space when the size of the split pane
* changes. A value of 0, the default,
* extra space.
*
* @param value as described above
* @exception IllegalArgumentException if <code>value</code> is < 0 or > 1
* @since 1.3
* @beaninfo
* bound: true
* description: Specifies how to distribute extra space when the split pane
* resizes.
*/
throw new IllegalArgumentException("JSplitPane weight must be between 0 and 1");
}
double oldWeight = resizeWeight;
}
/**
* Returns the number that determines how extra space is distributed.
* @return how extra space is to be distributed on a resize of the
* split pane
* @since 1.3
*/
public double getResizeWeight() {
return resizeWeight;
}
/**
* Lays out the <code>JSplitPane</code> layout based on the preferred size
* of the children components. This will likely result in changing
* the divider location.
*/
public void resetToPreferredSizes() {
ui.resetToPreferredSizes(this);
}
}
/**
* Sets the divider location as a percentage of the
* <code>JSplitPane</code>'s size.
* <p>
* This method is implemented in terms of
* <code>setDividerLocation(int)</code>.
* This method immediately changes the size of the split pane based on
* its current size. If the split pane is not correctly realized and on
* screen, this method will have no effect (new divider location will
* become (current size * proportionalLocation) which is 0).
*
* @param proportionalLocation a double-precision floating point value
* @exception IllegalArgumentException if the specified location is < 0
* or > 1.0
* @beaninfo
* description: The location of the divider.
*/
if (proportionalLocation < 0.0 ||
proportionalLocation > 1.0) {
throw new IllegalArgumentException("proportional location must " +
"be between 0.0 and 1.0.");
}
if (getOrientation() == VERTICAL_SPLIT) {
} else {
}
}
/**
* Sets the location of the divider. This is passed off to the
* look and feel implementation, and then listeners are notified. A value
* less than 0 implies the divider should be reset to a value that
* After notifying the listeners, the last divider location is updated,
* via <code>setLastDividerLocation</code>.
*
* @param location an int specifying a UI-specific value (typically a
* pixel count)
* @beaninfo
* bound: true
* description: The location of the divider.
*/
int oldValue = dividerLocation;
// Notify UI.
}
// Then listeners
// And update the last divider location.
}
/**
* Returns the last value passed to <code>setDividerLocation</code>.
* The value returned from this method may differ from the actual
* divider location (if <code>setDividerLocation</code> was passed a
* value bigger than the curent size).
*
* @return an integer specifying the location of the divider
*/
public int getDividerLocation() {
return dividerLocation;
}
/**
* Returns the minimum location of the divider from the look and feel
* implementation.
*
* @return an integer specifying a UI-specific value for the minimum
* location (typically a pixel count); or -1 if the UI is
* <code>null</code>
* @beaninfo
* description: The minimum location of the divider from the L&F.
*/
public int getMinimumDividerLocation() {
return ui.getMinimumDividerLocation(this);
}
return -1;
}
/**
* Returns the maximum location of the divider from the look and feel
* implementation.
*
* @return an integer specifying a UI-specific value for the maximum
* location (typically a pixel count); or -1 if the UI is
* <code>null</code>
*/
public int getMaximumDividerLocation() {
return ui.getMaximumDividerLocation(this);
}
return -1;
}
/**
* Removes the child component, <code>component</code> from the
* pane. Resets the <code>leftComponent</code> or
* <code>rightComponent</code> instance variable, as necessary.
*
* @param component the <code>Component</code> to remove
*/
if (component == leftComponent) {
} else if (component == rightComponent) {
}
// Update the JSplitPane on the screen
revalidate();
repaint();
}
/**
* Removes the <code>Component</code> at the specified index.
* Updates the <code>leftComponent</code> and <code>rightComponent</code>
* instance variables as necessary, and then messages super.
*
* @param index an integer specifying the component to remove, where
*/
if (comp == leftComponent) {
} else if (comp == rightComponent) {
}
// Update the JSplitPane on the screen
revalidate();
repaint();
}
/**
* Removes all the child components from the split pane. Resets the
* <code>leftComonent</code> and <code>rightComponent</code>
* instance variables.
*/
public void removeAll() {
super.removeAll();
// Update the JSplitPane on the screen
revalidate();
repaint();
}
/**
* Returns true, so that calls to <code>revalidate</code>
* on any descendant of this <code>JSplitPane</code>
* will cause a request to be queued that
* will validate the <code>JSplitPane</code> and all its descendants.
*
* @return true
* @see JComponent#revalidate
* @see java.awt.Container#isValidateRoot
*
* @beaninfo
* hidden: true
*/
public boolean isValidateRoot() {
return true;
}
/**
* Adds the specified component to this split pane.
* was previously added, it will be removed and then <code>comp</code>
* will be added in its place. If <code>constraints</code> is not
* one of the known identifiers the layout manager may throw an
* <code>IllegalArgumentException</code>.
* <p>
* The possible constraints objects (Strings) are:
* <ul>
* <li>JSplitPane.TOP
* <li>JSplitPane.LEFT
* <li>JSplitPane.BOTTOM
* <li>JSplitPane.RIGHT
* </ul>
* If the <code>constraints</code> object is <code>null</code>,
* the component is added in the
*
* @param comp the component to add
* @param constraints an <code>Object</code> specifying the
* layout constraints
* (position) for this component
* @param index an integer specifying the index in the container's
* list.
* @exception IllegalArgumentException if the <code>constraints</code>
* object does not match an existing component
* @see java.awt.Container#addImpl(Component, Object, int)
*/
{
throw new IllegalArgumentException("cannot add to layout: " +
"constraint must be a string " +
"(or null)");
}
if (constraints == null) {
if (getLeftComponent() == null) {
} else if (getRightComponent() == null) {
}
}
/* Find the Component that already exists and remove it. */
toRemove = getLeftComponent();
}
index = -1;
} else if (constraints != null &&
}
index = -1;
} else if (constraints != null &&
index = -1;
}
/* LayoutManager should raise for else condition here. */
// Update the JSplitPane on the screen
revalidate();
repaint();
}
/**
* Subclassed to message the UI with <code>finishedPaintingChildren</code>
* after super has been messaged, as well as painting the border.
*
* @param g the <code>Graphics</code> context within which to paint
*/
super.paintChildren(g);
}
}
/**
* See <code>readObject</code> and <code>writeObject</code> in
* <code>JComponent</code> for more
* information about serialization in Swing.
*/
s.defaultWriteObject();
}
}
}
if (propertyName == "dividerSize") {
if (!dividerSizeSet) {
dividerSizeSet = false;
}
} else if (propertyName == "oneTouchExpandable") {
if (!oneTouchExpandableSet) {
oneTouchExpandableSet = false;
}
} else {
}
}
/**
* Returns a string representation of this <code>JSplitPane</code>.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
* be <code>null</code>.
*
* @return a string representation of this <code>JSplitPane</code>.
*/
"HORIZONTAL_SPLIT" : "VERTICAL_SPLIT");
"true" : "false");
"true" : "false");
return super.paramString() +
",continuousLayout=" + continuousLayoutString +
",dividerSize=" + dividerSize +
",lastDividerLocation=" + lastDividerLocation +
",oneTouchExpandable=" + oneTouchExpandableString +
",orientation=" + orientationString;
}
///////////////////////////
// Accessibility support //
///////////////////////////
/**
* Gets the AccessibleContext associated with this JSplitPane.
* For split panes, the AccessibleContext takes the form of an
* AccessibleJSplitPane.
* A new AccessibleJSplitPane instance is created if necessary.
*
* @return an AccessibleJSplitPane that serves as the
* AccessibleContext of this JSplitPane
* @beaninfo
* expert: true
* description: The AccessibleContext associated with this SplitPane.
*/
if (accessibleContext == null) {
accessibleContext = new AccessibleJSplitPane();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the
* <code>JSplitPane</code> class. It provides an implementation of the
* Java Accessibility API appropriate to split pane user-interface elements.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
implements AccessibleValue {
/**
* Gets the state set of this object.
*
* @return an instance of AccessibleState containing the current state
* of the object
* @see AccessibleState
*/
// FIXME: [[[WDW - Should also add BUSY if this implements
// Adjustable at some point. If this happens, we probably
// should also add actions.]]]
if (getOrientation() == VERTICAL_SPLIT) {
} else {
}
return states;
}
/**
* Get the AccessibleValue associated with this object. In the
* implementation of the Java Accessibility API for this class,
* return this object, which is responsible for implementing the
* AccessibleValue interface on behalf of itself.
*
* @return this object
*/
return this;
}
/**
* Gets the accessible value of this object.
*
* @return a localized String describing the value of this object
*/
}
/**
* Sets the value of this object as a Number.
*
* @return True if the value was set.
*/
// TIGER - 4422535
if (n == null) {
return false;
}
setDividerLocation(n.intValue());
return true;
}
/**
* Gets the minimum accessible value of this object.
*
* @return The minimum value of this object.
*/
JSplitPane.this));
}
/**
* Gets the maximum accessible value of this object.
*
* @return The maximum value of this object.
*/
JSplitPane.this));
}
/**
* Gets the role of this object.
*
* @return an instance of AccessibleRole describing the role of
* the object
* @see AccessibleRole
*/
return AccessibleRole.SPLIT_PANE;
}
} // inner class AccessibleJSplitPane
}