image thumbnail

UISplitPane - Split a container (figure/frame/uipan​el) into two resizable sub-containers

versión (68.9 KB) por Yair Altman
Split a container (figure/frame/uipanel) into two resizable sub-containers, like Java's JSplitPane

6,2K descargas

Actualizada 14 Jan 2015

Ver licencia

Nota del editor: This file was selected as MATLAB Central Pick of the Week

[h1,h2,hDivider] = uisplitpane(hParent,'propName',propVal,...)

UISPLITPANE splits the specified container(s) (figure, panel or frame, referenced by handle(s) hParent) into two distinct panes (panels) separated by a movable divider. If no hParent container is specified, then the current figure (gcf) is assumed. Matlab components may freely be added to each of the panes. Pane sizes may be modified by dragging or programmatically repositioning the movable divider.
UISPLITPANE returns the handles to the left/bottom sub-container h1, right/top sub-container h2, and the split-pane divider hDivider. If a vector of several hParents was specified, then h1,h2 & hDivider will be corresponding vectors in the containing hParents. If the hParents are found to be non-unique, then the returned handles will correspond to the unique sorted vector of hParents, so that no hParent will be split more than once.

The UISPLITPANE divider can be dragged to either side, up to the specified DividerMinLocation to DividerMaxLocation property values (defaults: 0.1 and 0.9 respectively, meaning between 10-90% of range). In Matlab 7+, additional one-click buttons are added to the divider, which enable easy flushing of the divider to either side, regardless of DividerMinLocation & DividerMaxLocation property values.

Several case-insensitive properties may be specified as P-V pairs:
- 'Orientation': 'horizontal' (default) or 'vertical'
- 'Parent': Handle(s) of containing figure/panel/frame
- 'DividerWidth': Divider width (1-25 [pixels], default=5)
- 'DividerColor': Divider color (default=figure background color)
- 'DividerLocation': Divider normalized initial location (.001-.999, default=0.5)
- 'DividerMinLocation': Normalized minimal left/bottom pane size (0-1, default=0.1)
- 'DividerMaxLocation': Normalized maximal left/bottom pane size (0-1, default=0.9)

hDivider is a standard Matlab object handle possessing all these additional properties. All these properties are gettable/settable via the hDivider handle, except for the 'Orientation' & 'Parent' properties which become read-only after the UISPLITPANE is constructed. hDivider also exposes the following read-only properties:
- 'LeftOrBottomPaneHandle': h1 value returned by this function
- 'RightOrTopPaneHandle': h2 value returned by this function
- 'DividerHandle': the HG container handle (a numeric value)
- 'JavaComponent': handle to the underlying java divider obj
- 'ContainerParentHandle': handle to hParent container
Note: this is important in Matlab 6 which does
^^^^ not allow hierarchical UI containers
- 'ContainerParentVarName': hParent variable name if available

hax1=axes('Parent',hUp); plot(t,sin(t));
hax2=axes('parent',hLeft); plot(t,cos(t));
hax3=axes('parent',hRight); plot(t,tan(t));
hDiv1.DividerLocation = 0.75; % one way to modify divider...
set(hDiv2,'DividerColor','red'); % ...and this is another way...

Technical description:

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 6+, but use at your own risk!

Citar como

Yair Altman (2022). UISplitPane - Split a container (figure/frame/uipanel) into two resizable sub-containers (, MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R12
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!