public class MultiSplitLayout extends Object implements LayoutManager
Although MultiSplitLayout can be used with any Container, it's the default layout manager for MultiSplitPane. MultiSplitPane supports interactively dragging the Dividers, accessibility, and other features associated with split panes.
All properties in this class are bound: when a properties value is changed, all PropertyChangeListeners are fired.
MultiSplitPane
Modifier and Type | Class and Description |
---|---|
static class |
MultiSplitLayout.Divider
Models a single vertical/horiztonal divider.
|
static class |
MultiSplitLayout.InvalidLayoutException
The specified Node is either the wrong type or was configured
incorrectly.
|
static class |
MultiSplitLayout.Leaf
Models a java.awt Component child.
|
static class |
MultiSplitLayout.Node
Base class for the nodes that model a MultiSplitLayout.
|
static class |
MultiSplitLayout.Split
Defines a vertical or horizontal subdivision into two or more
tiles.
|
Constructor and Description |
---|
MultiSplitLayout()
Create a MultiSplitLayout with a default model with a single
Leaf node named "default".
|
MultiSplitLayout(MultiSplitLayout.Node model)
Create a MultiSplitLayout with the specified model.
|
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(String name,
Component child)
Add a component to this MultiSplitLayout.
|
void |
addPropertyChangeListener(PropertyChangeListener listener) |
MultiSplitLayout.Divider |
dividerAt(int x,
int y)
Return the Divider whose bounds contain the specified
point, or null if there isn't one.
|
List<MultiSplitLayout.Divider> |
dividersThatOverlap(Rectangle r)
Return the Dividers whose bounds overlap the specified
Rectangle.
|
int |
getDividerSize()
Returns the width of Dividers in Split rows, and the height of
Dividers in Split columns.
|
boolean |
getFloatingDividers() |
MultiSplitLayout.Node |
getModel()
Return the root of the tree of Split, Leaf, and Divider nodes
that define this layout.
|
PropertyChangeListener[] |
getPropertyChangeListeners() |
void |
layoutContainer(Container parent)
Compute the bounds of all of the Split/Divider/Leaf Nodes in
the layout model, and then set the bounds of each child component
with a matching Leaf Node.
|
Dimension |
minimumLayoutSize(Container parent) |
static MultiSplitLayout.Node |
parseModel(String s)
A convenience method that converts a string to a
MultiSplitLayout model (a tree of Nodes) using a
a simple syntax.
|
Dimension |
preferredLayoutSize(Container parent) |
static void |
printModel(MultiSplitLayout.Node root)
Print the tree with enough detail for simple debugging.
|
void |
removeLayoutComponent(Component child)
Removes the specified component from the layout.
|
void |
removePropertyChangeListener(PropertyChangeListener listener) |
void |
setDividerSize(int dividerSize)
Sets the width of Dividers in Split rows, and the height of
Dividers in Split columns.
|
void |
setFloatingDividers(boolean floatingDividers)
If true, Leaf node bounds match the corresponding component's
preferred size and Splits/Dividers are resized accordingly.
|
void |
setModel(MultiSplitLayout.Node model)
Set the root of the tree of Split, Leaf, and Divider nodes
that define this layout.
|
public MultiSplitLayout()
public MultiSplitLayout(MultiSplitLayout.Node model)
public void addPropertyChangeListener(PropertyChangeListener listener)
public void removePropertyChangeListener(PropertyChangeListener listener)
public PropertyChangeListener[] getPropertyChangeListeners()
public MultiSplitLayout.Node getModel()
setModel(org.jdesktop.swingx.MultiSplitLayout.Node)
public void setModel(MultiSplitLayout.Node model)
model
- the root of the tree of Split, Leaf, and Divider nodeIllegalArgumentException
- if model is a Divider or nullgetModel()
public int getDividerSize()
setDividerSize(int)
public void setDividerSize(int dividerSize)
dividerSize
- the size of dividers (pixels)IllegalArgumentException
- if dividerSize < 0getDividerSize()
public boolean getFloatingDividers()
setFloatingDividers(boolean)
public void setFloatingDividers(boolean floatingDividers)
getFloatingDividers()
public void addLayoutComponent(String name, Component child)
name
should match the name property of the Leaf
node that represents the bounds of child
. After
layoutContainer() recomputes the bounds of all of the nodes in
the model, it will set this child's bounds to the bounds of the
Leaf node with name
. Note: if a component was already
added with the same name, this method does not remove it from
its parent.addLayoutComponent
in interface LayoutManager
name
- identifies the Leaf node that defines the child's boundschild
- the component to be addedremoveLayoutComponent(java.awt.Component)
public void removeLayoutComponent(Component child)
removeLayoutComponent
in interface LayoutManager
child
- the component to be removedaddLayoutComponent(java.lang.String, java.awt.Component)
public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
in interface LayoutManager
public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize
in interface LayoutManager
public void layoutContainer(Container parent)
layoutContainer
in interface LayoutManager
public MultiSplitLayout.Divider dividerAt(int x, int y)
x
- x coordinatey
- y coordinatepublic List<MultiSplitLayout.Divider> dividersThatOverlap(Rectangle r)
r
- target RectangleIllegalArgumentException
- if the Rectangle is nullpublic static MultiSplitLayout.Node parseModel(String s)
For example, the following expression generates a horizontal Split node with three children: the Leafs named left and right, and a Divider in between:
(ROW (LEAF name=left) (LEAF name=right weight=1.0))
Dividers should not be included in the string, they're added automatcially as needed. Because Leaf nodes often only need to specify a name, one can specify a Leaf by just providing the name. The previous example can be written like this:
(ROW left (LEAF name=right weight=1.0))
Here's a more complex example. One row with three elements, the first and last of which are columns with two leaves each:
(ROW (COLUMN weight=0.5 left.top left.bottom) (LEAF name=middle) (COLUMN weight=0.5 right.top right.bottom))
This syntax is not intended for archiving or configuration files . It's just a convenience for examples and tests.
public static void printModel(MultiSplitLayout.Node root)
Copyright © 2023. All rights reserved.