MathWorks Machine Translation
The automated translation of this page is provided by a general purpose third party translator tool.
MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.
Control panel appearance
Valid for panels used in App Designer
or figures created with the uifigure function. For
panels used in GUIDE or apps created with the figure function,
see Uipanel Properties.
Panels are app components that contain other components. Typically, you use them to organize components in your app. Properties control the appearance and behavior of a particular instance of a panel. To modify aspects of a panel, change property values. Use dot notation to refer to a particular object and property.
f = uifigure;
p = uipanel('Parent', f);
title = p.Title;
p.Title = 'Display Options';

Title — panel title'' (default) | character vectorPanel title, specified as a character vector.
MATLAB® does not interpret a vertical slash ('|')
character as a line break, it displays as a vertical slash in the
panel title.
If you want to specify a Unicode® character, pass the Unicode decimal
code to the char function.
For example, ['Multiples of ' char(960)] displays
as Multiples of π
Example: 'Options'
Example: ['Multiples
of ' char(960)]
TitlePosition — Location of panel title'lefttop' (default) | 'centertop' | 'righttop'Location of the panel title, specified as 'lefttop', 'centertop',
or 'righttop'.
BackgroundColor — Panel background color[.94 .94 .94] (default) | RGB triplet | short name | long namePanel background color, specified as an RGB triplet, short name, or long name. The color you specify fills the area bounded by the panel.
An RGB triplet is a three-element row vector whose elements
specify the intensities of the red, green, and blue components of
the color. The intensities must be in the range [0,1];
for example, [0.4 0.6 0.7]. This table lists the
long and short color name options and the equivalent RGB triplet values.
| Long Name | Short Name | RGB Triplet |
|---|---|---|
'yellow' | 'y' | [1 1 0] |
'magenta' | 'm' | [1 0 1] |
'cyan' | 'c' | [0 1 1] |
'red' | 'r' | [1 0 0] |
'green' | 'g' | [0 1 0] |
'blue' | 'b' | [0 0 1] |
'white' | 'w' | [1 1 1] |
'black' | 'k' | [0 0 0] |
Example: [0 0 1]
Example: 'b'
Example: 'blue'
BorderType — Panel border'line' (default) | 'none'Panel border, specified as 'line' or 'none'.
Visible — Panel visibility'on' (default) | 'off'Panel visibility, specified as 'on' or 'off'.
The Visible property determines whether the panel
is displayed on the screen. If the Visible property
of a panel is set to 'off', the panel is hidden.
However, you can still specify and access its properties.
To make your app start faster, set the Visible property
of all components that are not initially displayed to 'off'.
Note
Changing the |
Position — Location and size of panel, including borders and title[left bottom width height]Location and size of the panel, including borders and title,
specified as a four-element vector of the form [left bottom
width height]. This table describes each element in the
vector.
| Element | Description |
|---|---|
left | Distance from the inner left edge of the parent container to the outer left edge of the panel |
bottom | Distance from the inner bottom edge of the parent container to the outer bottom edge of the panel |
width | Distance between the right and left outer edges of the panel |
height | Distance between the top and bottom outer edges of the panel |
All measurements are in units
specified by the Units property.
Note:
The |
OuterPosition — Location and size of panel, including borders and title[left bottom width height]Location and size of the panel, including borders and title,
specified as a four-element vector of the form [left bottom
width height]. All measurements are in units specified by
the Units property.
This property value is identical to the Position property
value.
InnerPosition — Location and size of panel, excluding borders and title[left bottom width height]This property is read only.
Location and size of the panel, excluding borders and title,
returned as a four-element vector of the form [left bottom
width height]. This table describes each element in the
vector.
| Value | Description |
|---|---|
left | Distance from the inner left edge of the parent container to the inner left edge of the panel. |
bottom | Distance from the inner bottom edge of the parent container to the inner bottom edge of the panel. |
width | Distance between the inner edges of the panel's right and left borders. |
height | Distance between the inner edges of the panel's top and bottom borders. This distance excludes the title, if it exists. |
All measurements are in units
specified by the Units property.
Note:
These are some important points to consider when using the
|
Units — Units of measurement'pixels' (default)Units of measurement, specified as 'pixels'.
SizeChangedFcn — Code to execute when panel resizes'' (default) | function handle | cell array | character vectorCode to execute when panel resizes programmatically, specified as one of these values:
Function handle
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector that is a valid MATLAB expression. MATLAB evaluates this expression in the base workspace.
Define this callback function to control the app layout when the app user changes the size of the panel.
The SizeChangedFcn callback executes under
these circumstances:
The panel becomes visible for the first time.
The panel is visible while its size changes.
The panel becomes visible for the first time after its size changes. This situation occurs when the size changes while the panel is invisible, and then it becomes visible later.
These are some of the important characteristics of the SizeChangedFcn callback
and some recommended best practices:
Consider delaying the display of the figure until
after all the variables that the panel 's SizeChangedFcn uses
are defined. This practice can prevent the panel's SizeChangedFcn callback
from returning an error. To delay the display of the figure, set its Visible property
to 'off'. Then, set the Visible property
to 'on' after you define the variables that your SizeChangedFcn callback
uses.
Use the gcbo function
in your SizeChangedFcn code to get the panel
object that is resizing. See the description of the figure SizeChangedFcn for
an example that uses gcbo.
All visible, nested panels resize from the inside out.
Example: @myfun
Example: {@myfun,x}
FontName — Font in which to display TitleFont in which to display the Title property
value, specified as a system supported font name. The default font
depends on the specific operating system and locale.
If the specified font is not available, then MATLAB uses the best match among the fonts available on the system where the app is running.
Example: 'Arial'
ForegroundColor — Title color[0 0 0] (default) | RGB triplet | short name | long nameTitle color, specified as an RGB triplet,
short name, or long name.
An RGB triplet is a three-element row vector whose elements
specify the intensities of the red, green, and blue components of
the color. The intensities must be in the range [0,1],
for example, [0.4 0.6 0.7]. This table lists the
long and short color name options and the equivalent RGB triplet values.
| Long Name | Short Name | RGB Triplet |
|---|---|---|
'yellow' | 'y' | [1 1 0] |
'magenta' | 'm' | [1 0 1] |
'cyan' | 'c' | [0 1 1] |
'red' | 'r' | [1 0 0] |
'green' | 'g' | [0 1 0] |
'blue' | 'b' | [0 0 1] |
'white' | 'w' | [1 1 1] |
'black' | 'k' | [0 0 0] |
Example: [0 0 1]
Example: 'b'
Example: 'blue'
FontSize — Font size of Title Font size of the Title property value,
specified as a positive number. The units of measurement are pixels.
Example: 14
FontUnits — Font unit of measurement'pixels' (default)Font unit of measurement, specified as 'pixels'.
Distances in pixels are independent of your system resolution on Windows® and
Macintosh systems:
On Windows systems, a pixel is 1/96th of an inch.
On Macintosh systems, a pixel is 1/72nd of an inch.
On Linux® systems, the size of a pixel is determined by your system resolution.
FontWeight — Thickness of Title 'normal' (default) | 'bold'Thickness of the Title property value,
specified as one of these values:
'normal' — Default weight
as defined by the particular font
'bold' — Thicker character
outlines than 'normal'
Not all fonts have a bold font weight. Therefore, specifying a bold font weight can result in the normal font weight.
FontAngle — Character slant of Title'normal' (default) | 'italic'Character slant of the Title property value
specified as 'normal' or 'italic'.
Setting this property to italic selects a slanted
version of the font, if it is available on the app user's system.
Interruptible — Callback interruptibility status'on' (default) | 'off'Callback interruptibility status, specified as 'on' or 'off'.
The Interruptible property determines if a running
callback can be interrupted.
There are two callback states to consider:
The running callback is the currently executing callback.
The interrupting callback is a callback that tries to interrupt the running callback.
Whenever MATLAB invokes a callback, that callback
attempts to interrupt the running callback. The Interruptible property
of the object owning the running callback determines if interruption
is allowed. If interruption is not allowed, then the BusyAction property
of the object owning the interrupting callback determines if it is
discarded or put into a queue.

If a callback is the running callback, then the Interruptible property
determines if it can be interrupted by another callback. The Interruptible property
has two possible values:
'off' — A callback cannot
interrupt the running callback. MATLAB finishes executing the
running callback without any interruptions. This is the default behavior.
'on' — A callback can interrupt
the running callback. The interruption occurs at the next point where MATLAB processes
the queue, such as when there is a drawnow, uifigure, getframe, waitfor, or pause command.
If the running callback contains one of the commands, then MATLAB stops the execution of the callback at this point and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes.
If the running callback does not contain one of these commands, then MATLAB finishes executing the callback without interruption.
Note: Callback interruption and execution behave differently in these situations:
When an interruption occurs, MATLAB does not save the state
of properties or the display . For example, the handle returned by
the |
BusyAction — Callback queuing'queue' (default) | 'cancel'Callback queuing, specified as 'queue' or 'cancel'.
The BusyAction property determines how MATLAB handles
the execution of interrupting callbacks. There are two callback states
to consider:
The running callback is the currently executing callback.
The interrupting callback is a callback that tries to interrupt the running callback.
The BusyAction property of the object that
owns the interrupting callback determines how MATLAB handles
the execution of the interrupting callback. The BusyAction property
has two possible values:
'queue' — Put the interrupting
callback in a queue to be processed after the running callback finishes
execution.
'cancel' — Do not execute
the interrupting callback.
Whenever MATLAB invokes a callback, that callback always
attempts to interrupt an executing callback (if one exists). The Interruptible property
of the object whose callback is executing determines if interruption
is allowed. The Interruptible property has two
possible values:
'on' — Interruption occurs
at the next point where MATLAB processes the queue. This is the
default.
'off' — BusyAction property
(of the object owning the interrupting callback) determines if MATLAB enqueues
or ignores the interrupting callback.
BeingDeleted — Deletion status of this component'off' (default) | 'on'This property is read only.
Deletion status of this component, returned as 'off' or 'on'. MATLAB sets
the BeingDeleted property to 'on' when
the DeleteFcn callback begins execution. The BeingDeleted property
remains set to 'on' until the component object
no longer exists.
Check the value of the BeingDeleted property
to verify that the object is not about to be deleted before querying
or modifying it.
CreateFcn — Component creation functionComponent creation function, specified as one of these values:
A function handle.
A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
A character vector containing a valid MATLAB expression.
For example, 'disp(''hello world'')' calls the disp function. MATLAB evaluates
this expression in the base workspace.
This property specifies a callback function to execute when MATLAB creates
this component in the app. MATLAB initializes all property values
before executing the CreateFcn callback. If you
do not specify the CreateFcn property, then MATLAB executes
a default creation function.
Use the gcbo function
in your CreateFcn code to get the component that
is being created.
Setting the CreateFcn property on an existing
component has no effect.
DeleteFcn — Component deletion functionComponent deletion function, specified as one of these values:
A function handle.
A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
A character vector containing a valid MATLAB expression.
For example, 'disp(''hello world'')' calls the disp function. MATLAB evaluates
this expression in the base workspace.
The DeleteFcn property specifies a callback
function to execute when MATLAB deletes a component in an app. MATLAB executes
the DeleteFcn callback before destroying the
properties of the object. If you do not specify the DeleteFcn property,
then MATLAB executes a default deletion function.
Use the gcbo function
in your DeleteFcn code to access the component
that is being deleted.
Type — Type of graphics object'uipanel'This property is read only.
Type of graphics object, returned as 'uipanel'.
Tag — Object identifier'' (default) | character vectorObject identifier, specified as a character vector. You can
specify a unique Tag value to serve as an identifier
for any component object in your app. When you need access to the
object elsewhere in your code, you can use the findobj function to search for the object
based on the Tag value.
Example: 'panel1'
UserData — Data to associate with this componentData to associate with this component, specified as any array.
Specifying UserData can be useful for sharing
data values within and across apps you create programmatically.
Note: Do not use this property in apps you create with App Designer. For information on sharing data values within and across apps created with App Designer, see Share Data Across Callbacks in App Designer. |
Example: [1 2 3]
Example: 'April
21'
Example: struct('value1',[1
2 3],'value2','April 21')
Example: {[1
2 3],'April 21'}
Parent — Panel objectParent object, specified as a figure, panel, tab, or button
group object. The parent object must be either a figure created using
the uifigure function, or the child of a figure
created using the uifigure function.
Children — Panel child objectsGraphicsPlaceholder array (default) | 1-D array of component objectsPanel child objects, returned as an empty GraphicsPlaceholder or
a 1-D array of component objects. The children of a panel can be any
component, including another panel.
You cannot add or remove child components using the Children property
of the panel. Use this property to view the list of children or to
reorder the children. The order of the child objects in this array
reflects the front-to-back stacking order of the components on the
screen.
To add a child object to this list, set the Parent property
of the child object to this panel.
HandleVisibility — Panel handle visibility 'on' (default) | 'callback' | 'off'Panel handle visibility in its parent's list of children,
specified as 'on', 'callback',
or 'off'.
This property controls the visibility of the panel handle in
its parent's list of children. When a panel is not visible in its
parent's list of children, it is not returned by the get function, which obtains handles by
searching the object hierarchy or querying handle properties. Handles
are still valid even if they are not visible. If you know an object's
handle, you can set and get its properties, and pass it to any function
that operates on handles.
| HandleVisibility Value | Description |
|---|---|
'on' | The panel handle is always visible. |
'callback' | The panel handle is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line. This option blocks access to the panel at the command-line, but allows callback functions to access it. |
'off' | The panel handle is invisible at all times. This option is
useful for preventing unintended changes to the UI by another function.
Set the HandleVisibility to 'off' to
temporarily hide the handle during the execution of that function.
|
You can also select a location from the following list: