Fields Summary |
---|
private static final String | uiClassID |
public static final int | VERTICAL_SPLITVertical split indicates the Component s are
split along the y axis. For example the two
Component s will be split one on top of the other. |
public static final int | HORIZONTAL_SPLITHorizontal split indicates the Component s are
split along the x axis. For example the two
Component s will be split one to the left of the
other. |
public static final String | LEFTUsed to add a Component to the left of the other
Component . |
public static final String | RIGHTUsed to add a Component to the right of the other
Component . |
public static final String | TOPUsed to add a Component above the other
Component . |
public static final String | BOTTOMUsed to add a Component below the other
Component . |
public static final String | DIVIDERUsed to add a Component that will represent the divider. |
public static final String | ORIENTATION_PROPERTYBound property name for orientation (horizontal or vertical). |
public static final String | CONTINUOUS_LAYOUT_PROPERTYBound property name for continuousLayout. |
public static final String | DIVIDER_SIZE_PROPERTYBound property name for border. |
public static final String | ONE_TOUCH_EXPANDABLE_PROPERTYBound property for oneTouchExpandable. |
public static final String | LAST_DIVIDER_LOCATION_PROPERTYBound property for lastLocation. |
public static final String | DIVIDER_LOCATION_PROPERTYBound property for the dividerLocation. |
public static final String | RESIZE_WEIGHT_PROPERTYBound property for weight. |
protected int | orientationHow the views are split. |
protected boolean | continuousLayoutWhether or not the views are continuously redisplayed while
resizing. |
protected Component | leftComponentThe left or top component. |
protected Component | rightComponentThe right or bottom component. |
protected int | dividerSizeSize of the divider. |
private boolean | dividerSizeSet |
protected boolean | oneTouchExpandableIs a little widget provided to quickly expand/collapse the
split pane? |
private boolean | oneTouchExpandableSet |
protected int | lastDividerLocationPrevious location of the split pane. |
private double | resizeWeightHow to distribute extra space. |
private int | dividerLocationLocation of the divider, at least the value that was set, the UI may
have a different value. |
Constructors Summary |
---|
public JSplitPane()Creates a new JSplitPane configured to arrange the child
components side-by-side horizontally with no continuous
layout, using two buttons for the components.
this(JSplitPane.HORIZONTAL_SPLIT, false,
new JButton(UIManager.getString("SplitPane.leftButtonText")),
new JButton(UIManager.getString("SplitPane.rightButtonText")));
|
public JSplitPane(int newOrientation)Creates a new JSplitPane configured with the
specified orientation and no continuous layout.
this(newOrientation, false);
|
public JSplitPane(int newOrientation, boolean newContinuousLayout)Creates a new JSplitPane with the specified
orientation and redrawing style.
this(newOrientation, newContinuousLayout, null, null);
|
public JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)Creates a new JSplitPane with the specified
orientation and
with the specified components that do not do continuous
redrawing.
this(newOrientation, false, newLeftComponent, newRightComponent);
|
public JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)Creates a new JSplitPane with the specified
orientation and
redrawing style, and with the specified components.
super();
dividerLocation = -1;
setLayout(null);
setUIProperty("opaque", Boolean.TRUE);
orientation = newOrientation;
if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)
throw new IllegalArgumentException("cannot create JSplitPane, " +
"orientation must be one of " +
"JSplitPane.HORIZONTAL_SPLIT " +
"or JSplitPane.VERTICAL_SPLIT");
continuousLayout = newContinuousLayout;
if (newLeftComponent != null)
setLeftComponent(newLeftComponent);
if (newRightComponent != null)
setRightComponent(newRightComponent);
updateUI();
|
Methods Summary |
---|
protected void | addImpl(java.awt.Component comp, java.lang.Object constraints, int index)Adds the specified component to this split pane.
If constraints identifies the left/top or
right/bottom child component, and a component with that identifier
was previously added, it will be removed and then comp
will be added in its place. If constraints is not
one of the known identifiers the layout manager may throw an
IllegalArgumentException .
The possible constraints objects (Strings) are:
- JSplitPane.TOP
- JSplitPane.LEFT
- JSplitPane.BOTTOM
- JSplitPane.RIGHT
If the constraints object is null ,
the component is added in the
first available position (left/top if open, else right/bottom).
Component toRemove;
if (constraints != null && !(constraints instanceof String)) {
throw new IllegalArgumentException("cannot add to layout: " +
"constraint must be a string " +
"(or null)");
}
/* If the constraints are null and the left/right component is
invalid, add it at the left/right component. */
if (constraints == null) {
if (getLeftComponent() == null) {
constraints = JSplitPane.LEFT;
} else if (getRightComponent() == null) {
constraints = JSplitPane.RIGHT;
}
}
/* Find the Component that already exists and remove it. */
if (constraints != null && (constraints.equals(JSplitPane.LEFT) ||
constraints.equals(JSplitPane.TOP))) {
toRemove = getLeftComponent();
if (toRemove != null) {
remove(toRemove);
}
leftComponent = comp;
index = -1;
} else if (constraints != null &&
(constraints.equals(JSplitPane.RIGHT) ||
constraints.equals(JSplitPane.BOTTOM))) {
toRemove = getRightComponent();
if (toRemove != null) {
remove(toRemove);
}
rightComponent = comp;
index = -1;
} else if (constraints != null &&
constraints.equals(JSplitPane.DIVIDER)) {
index = -1;
}
/* LayoutManager should raise for else condition here. */
super.addImpl(comp, constraints, index);
// Update the JSplitPane on the screen
revalidate();
repaint();
|
public javax.accessibility.AccessibleContext | getAccessibleContext()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.
if (accessibleContext == null) {
accessibleContext = new AccessibleJSplitPane();
}
return accessibleContext;
|
public java.awt.Component | getBottomComponent()Returns the component below, or to the right of the divider.
return rightComponent;
|
public int | getDividerLocation()Returns the last value passed to setDividerLocation .
The value returned from this method may differ from the actual
divider location (if setDividerLocation was passed a
value bigger than the curent size).
return dividerLocation;
|
public int | getDividerSize()Returns the size of the divider.
return dividerSize;
|
public int | getLastDividerLocation()Returns the last location the divider was at.
return lastDividerLocation;
|
public java.awt.Component | getLeftComponent()Returns the component to the left (or above) the divider.
return leftComponent;
|
public int | getMaximumDividerLocation()Returns the maximum location of the divider from the look and feel
implementation.
SplitPaneUI ui = getUI();
if (ui != null) {
return ui.getMaximumDividerLocation(this);
}
return -1;
|
public int | getMinimumDividerLocation()Returns the minimum location of the divider from the look and feel
implementation.
SplitPaneUI ui = getUI();
if (ui != null) {
return ui.getMinimumDividerLocation(this);
}
return -1;
|
public int | getOrientation()Returns the orientation.
return orientation;
|
public double | getResizeWeight()Returns the number that determines how extra space is distributed.
return resizeWeight;
|
public java.awt.Component | getRightComponent()Returns the component to the right (or below) the divider.
return rightComponent;
|
public java.awt.Component | getTopComponent()Returns the component above, or to the left of the divider.
return leftComponent;
|
public javax.swing.plaf.SplitPaneUI | getUI()Returns the SplitPaneUI that is providing the
current look and feel.
return (SplitPaneUI)ui;
|
public java.lang.String | getUIClassID()Returns the name of the L&F class that renders this component.
return uiClassID;
|
public boolean | isContinuousLayout()Gets the continuousLayout property.
return continuousLayout;
|
public boolean | isOneTouchExpandable()Gets the oneTouchExpandable property.
return oneTouchExpandable;
|
public boolean | isValidateRoot()Returns true, so that calls to revalidate
on any descendant of this JSplitPane
will cause a request to be queued that
will validate the JSplitPane and all its descendants.
return true;
|
protected void | paintChildren(java.awt.Graphics g)Subclassed to message the UI with finishedPaintingChildren
after super has been messaged, as well as painting the border.
super.paintChildren(g);
SplitPaneUI ui = getUI();
if (ui != null) {
Graphics tempG = g.create();
ui.finishedPaintingChildren(this, tempG);
tempG.dispose();
}
|
protected java.lang.String | paramString()Returns a string representation of this JSplitPane .
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 null .
String orientationString = (orientation == HORIZONTAL_SPLIT ?
"HORIZONTAL_SPLIT" : "VERTICAL_SPLIT");
String continuousLayoutString = (continuousLayout ?
"true" : "false");
String oneTouchExpandableString = (oneTouchExpandable ?
"true" : "false");
return super.paramString() +
",continuousLayout=" + continuousLayoutString +
",dividerSize=" + dividerSize +
",lastDividerLocation=" + lastDividerLocation +
",oneTouchExpandable=" + oneTouchExpandableString +
",orientation=" + orientationString;
|
public void | remove(java.awt.Component component)Removes the child component, component from the
pane. Resets the leftComponent or
rightComponent instance variable, as necessary.
if (component == leftComponent) {
leftComponent = null;
} else if (component == rightComponent) {
rightComponent = null;
}
super.remove(component);
// Update the JSplitPane on the screen
revalidate();
repaint();
|
public void | remove(int index)Removes the Component at the specified index.
Updates the leftComponent and rightComponent
instance variables as necessary, and then messages super.
Component comp = getComponent(index);
if (comp == leftComponent) {
leftComponent = null;
} else if (comp == rightComponent) {
rightComponent = null;
}
super.remove(index);
// Update the JSplitPane on the screen
revalidate();
repaint();
|
public void | removeAll()Removes all the child components from the split pane. Resets the
leftComonent and rightComponent
instance variables.
leftComponent = rightComponent = null;
super.removeAll();
// Update the JSplitPane on the screen
revalidate();
repaint();
|
public void | resetToPreferredSizes()Lays out the JSplitPane layout based on the preferred size
of the children components. This will likely result in changing
the divider location.
SplitPaneUI ui = getUI();
if (ui != null) {
ui.resetToPreferredSizes(this);
}
|
public void | setBottomComponent(java.awt.Component comp)Sets the component below, or to the right of the divider.
setRightComponent(comp);
|
public void | setContinuousLayout(boolean newContinuousLayout)Sets the value of the continuousLayout property,
which must be true for the child components
to be continuously
redisplayed and laid out during user intervention.
The default value of this property is false .
Some look and feels might not support continuous layout;
they will ignore this property.
boolean oldCD = continuousLayout;
continuousLayout = newContinuousLayout;
firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldCD,
newContinuousLayout);
|
public void | setDividerLocation(double proportionalLocation)Sets the divider location as a percentage of the
JSplitPane 's size.
This method is implemented in terms of
setDividerLocation(int) .
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).
if (proportionalLocation < 0.0 ||
proportionalLocation > 1.0) {
throw new IllegalArgumentException("proportional location must " +
"be between 0.0 and 1.0.");
}
if (getOrientation() == VERTICAL_SPLIT) {
setDividerLocation((int)((double)(getHeight() - getDividerSize()) *
proportionalLocation));
} else {
setDividerLocation((int)((double)(getWidth() - getDividerSize()) *
proportionalLocation));
}
|
public void | setDividerLocation(int location)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
attempts to honor the preferred size of the left/top component.
After notifying the listeners, the last divider location is updated,
via setLastDividerLocation .
int oldValue = dividerLocation;
dividerLocation = location;
// Notify UI.
SplitPaneUI ui = getUI();
if (ui != null) {
ui.setDividerLocation(this, location);
}
// Then listeners
firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldValue, location);
// And update the last divider location.
setLastDividerLocation(oldValue);
|
public void | setDividerSize(int newSize)Sets the size of the divider.
int oldSize = dividerSize;
dividerSizeSet = true;
if (oldSize != newSize) {
dividerSize = newSize;
firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, newSize);
}
|
public void | setLastDividerLocation(int newLastLocation)Sets the last location the divider was at to
newLastLocation .
int oldLocation = lastDividerLocation;
lastDividerLocation = newLastLocation;
firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldLocation,
newLastLocation);
|
public void | setLeftComponent(java.awt.Component comp)Sets the component to the left (or above) the divider.
if (comp == null) {
if (leftComponent != null) {
remove(leftComponent);
leftComponent = null;
}
} else {
add(comp, JSplitPane.LEFT);
}
|
public void | setOneTouchExpandable(boolean newValue)Sets the value of the oneTouchExpandable property,
which must be true for the
JSplitPane to provide a UI widget
on the divider to quickly expand/collapse the divider.
The default value of this property is false .
Some look and feels might not support one-touch expanding;
they will ignore this property.
boolean oldValue = oneTouchExpandable;
oneTouchExpandable = newValue;
oneTouchExpandableSet = true;
firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, newValue);
repaint();
|
public void | setOrientation(int orientation)Sets the orientation, or how the splitter is divided. The options
are:
- JSplitPane.VERTICAL_SPLIT (above/below orientation of components)
- JSplitPane.HORIZONTAL_SPLIT (left/right orientation of components)
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;
firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, orientation);
|
public void | setResizeWeight(double value)Specifies how to distribute extra space when the size of the split pane
changes. A value of 0, the default,
indicates the right/bottom component gets all the extra space (the
left/top component acts fixed), where as a value of 1 specifies the
left/top component gets all the extra space (the right/bottom component
acts fixed). Specifically, the left/top component gets (weight * diff)
extra space and the right/bottom component gets (1 - weight) * diff
extra space.
if (value < 0 || value > 1) {
throw new IllegalArgumentException("JSplitPane weight must be between 0 and 1");
}
double oldWeight = resizeWeight;
resizeWeight = value;
firePropertyChange(RESIZE_WEIGHT_PROPERTY, oldWeight, value);
|
public void | setRightComponent(java.awt.Component comp)Sets the component to the right (or below) the divider.
if (comp == null) {
if (rightComponent != null) {
remove(rightComponent);
rightComponent = null;
}
} else {
add(comp, JSplitPane.RIGHT);
}
|
public void | setTopComponent(java.awt.Component comp)Sets the component above, or to the left of the divider.
setLeftComponent(comp);
|
public void | setUI(javax.swing.plaf.SplitPaneUI ui)Sets the L&F object that renders this component.
if ((SplitPaneUI)this.ui != ui) {
super.setUI(ui);
revalidate();
}
|
void | setUIProperty(java.lang.String propertyName, java.lang.Object value)
if (propertyName == "dividerSize") {
if (!dividerSizeSet) {
setDividerSize(((Number)value).intValue());
dividerSizeSet = false;
}
} else if (propertyName == "oneTouchExpandable") {
if (!oneTouchExpandableSet) {
setOneTouchExpandable(((Boolean)value).booleanValue());
oneTouchExpandableSet = false;
}
} else {
super.setUIProperty(propertyName, value);
}
|
public void | updateUI()Notification from the UIManager that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager .
setUI((SplitPaneUI)UIManager.getUI(this));
revalidate();
|
private void | writeObject(java.io.ObjectOutputStream s)See readObject and writeObject in
JComponent for more
information about serialization in Swing.
s.defaultWriteObject();
if (getUIClassID().equals(uiClassID)) {
byte count = JComponent.getWriteObjCounter(this);
JComponent.setWriteObjCounter(this, --count);
if (count == 0 && ui != null) {
ui.installUI(this);
}
}
|