Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Panel (App Designer) Properties

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';

Appearance

expand all

Panel 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)]

Location of the panel title, specified as 'lefttop', 'centertop', or 'righttop'.

Panel 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 NameShort NameRGB 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'

Panel border, specified as 'line' or 'none'.

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 Visible property of a panel does not change the values of the Visible properties of its child components. This is true even though hiding the panel causes the children to be hidden.

Location and Size

expand all

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.

ElementDescription
leftDistance from the inner left edge of the parent container to the outer left edge of the panel
bottomDistance from the inner bottom edge of the parent container to the outer bottom edge of the panel
widthDistance between the right and left outer edges of the panel
heightDistance between the top and bottom outer edges of the panel

All measurements are in units specified by the Units property.

    Note:   The Position values are relative to the drawable area of the parent container component (UI figure, button group, panel, or tab). The drawable area is the area inside the borders of the container and does not include the area occupied by the title.

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.

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.

ValueDescription
leftDistance from the inner left edge of the parent container to the inner left edge of the panel.
bottomDistance from the inner bottom edge of the parent container to the inner bottom edge of the panel.
widthDistance between the inner edges of the panel's right and left borders.
heightDistance 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 InnerPosition property:

    • InnerPosition values are affected by the presence (or absence) of a title, the font characteristics, and the BorderType.

    • InnerPosition values are relative to the parent container's drawable area. The drawable area is the area inside the borders of the container and does not include the area occupied by the title.

Units of measurement, specified as 'pixels'.

Interactive Control

expand all

Code 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}

Font Style

expand all

Font 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'

Title 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 NameShort NameRGB 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'

Font size of the Title property value, specified as a positive number. The units of measurement are pixels.

Example: 14

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.

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.

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.

Callback Execution Control

expand all

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:

    • If the interrupting callback is a DeleteFcn, CloseRequestFcn or SizeChangedFcn callback, then the interruption occurs regardless of the Interruptible property value.

    • If the running callback is currently executing the waitfor function, then the interruption occurs regardless of the Interruptible property value.

    • Timer objects execute according to schedule regardless of the Interruptible property value.

    When an interruption occurs, MATLAB does not save the state of properties or the display . For example, the handle returned by the gca or gcf command might change when another callback executes.

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.

Creation and Deletion Control

expand all

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.

Component 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.

    Note:   Do not call copyobj or textwrap (which calls copyobj) inside a CreateFcn. Copying the object causes the CreateFcn callback to execute repeatedly.

Component 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.

Identifiers

expand all

This property is read only.

Type of graphics object, returned as 'uipanel'.

Object 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'

Data 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.

Example: [1 2 3]

Example: 'April 21'

Example: struct('value1',[1 2 3],'value2','April 21')

Example: {[1 2 3],'April 21'}

Parent/Children

expand all

Parent 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.

Panel 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.

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 ValueDescription
'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.

See Also

Functions

Introduced in R2016a

Was this topic helpful?