| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
You can set and query graphics object properties in two ways:
The Property Inspector is an interactive tool that enables you to see and change object property values. The Property inspector is available from GUIDE, or use the inspect function at the command line.
The set and get functions enable you to set and query the values of properties.
You can set default uipanel properties by typing:
set(h,'DefaultUipanelPropertyName',PropertyValue...)Where h can be the root handle (0), a figure handle, or a uipanel handle. PropertyName is the name of the uipanel property and PropertyValue is the value you specify as the default for that property.
For more information about changing the default value of a property see Setting Default Property Values. For an example, see the CreateFcn property.
This section lists all properties useful to uipanel objects along with valid values and a descriptions of their use. Curly braces { } enclose default values.
Property Name | Description |
|---|---|
| BackgroundColor | Color of the uipanel background |
| BeingDeleted | This object is being deleted |
| BorderType | Type of border around the uipanel area. |
| BorderWidth | Width of the panel border. |
| BusyAction | Interruption of other callback routines |
| ButtonDownFcn | Button-press callback routine |
| Children | All children of the uipanel |
| Clipping | Clipping of child axes, uipanels, and uibuttongroups to the uipanel. Does not affect child uicontrols. |
| CreateFcn | Callback routine executed during object creation |
| DeleteFcn | Callback routine executed during object deletion |
| FontAngle | Title font angle |
| FontName | Title font name |
| FontSize | Title font size |
| FontUnits | Title font units |
| FontWeight | Title font weight |
| ForegroundColor | Title font color and/or color of 2-D border line |
| HandleVisibility | Handle accessibility from commandline and GUIs |
| HighlightColor | 3-D frame highlight color |
| Interruptible | Callback routine interruption mode |
| Parent | Uipanel object's parent |
| Position | Panel position relative to parent figure or uipanel |
| ResizeFcn | User-specified resize routine |
| Selected | Whether object is selected |
| SelectionHighlight | Object highlighted when selected |
| ShadowColor | 3-D frame shadow color |
| Tag | User-specified object identifier |
| Title | Title string |
| TitlePosition | Location of title string in relation to the panel |
| Type | Object class |
| UIContextMenu | Associates uicontextmenu with the uipanel |
| Units | Units used to interpret the position vector |
| UserData | User-specified data |
| Visible | Uipanel visibility. |
ColorSpec
Color of the uipanel background. A three-element RGB vector or one of the MATLAB predefined names, specifying the background color. See the ColorSpec reference page for more information on specifying color.
on | {off} Read Only
This object is being deleted. The BeingDeleted property provides a mechanism that you can use to determine if objects are in the process of being deleted. MATLAB sets the BeingDeleted property to on when the object's delete function callback is called (see the DeleteFcn property). It remains set to on while the delete function executes, after which the object no longer exists.
For example, an object's delete function might call other functions that act on a number of different objects. These functions might not need to perform actions on objects if the objects are going to be deleted, and therefore, can check the object's BeingDeleted property before acting.
none | {etchedin} | etchedout | beveledin | beveledout | line
Border of the uipanel area. Used to define the panel area graphically. Etched and beveled borders provide a 3-D look. Use the HighlightColor and ShadowColor properties to specify the border color of etched and beveled borders. A line border is 2-D. Use the ForegroundColor property to specify its color.
integer
Width of the panel border. The width of the panel borders in pixels. The default border width is 1 pixel. 3-D borders wider than 3 may not appear correctly at the corners.
cancel | {queue}
Callback routine interruption. If a callback is executing and the user triggers an event (such as a mouse click) on an object for which a callback is defined, the callback associated with the new event uses the value of BusyAction to decide whether or not to attempt to interrupt the executing callback.
If the value is cancel, the event is discarded and the second callback does not execute.
If the value is queue, and the Interruptible property of the first callback is on, the second callback is added to the event queue and executes in its turn after the first callback finishes execution.
Note If the interrupting callback is a DeleteFcn or CreateFcn callback or a figure's CloseRequest or ResizeFcn callback, it interrupts an executing callback regardless of the value of that object's Interruptible property. See the Interruptible property for information about controlling a callback's interruptibility. |
string or function handle
Button-press callback routine. A callback routine that executes when you press a mouse button while the pointer is in a 5-pixel wide border around the uipanel. This is useful for implementing actions to interactively modify control object properties, such as size and position, when they are clicked on (using the selectmoveresize function, for example).
If you define this routine as a string, the string can be a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.
vector of handles
Children of the uipanel. A vector containing the handles of all children of the uipanel. A uipanel object's children are axes, uipanels, uibuttongroups, and uicontrols. You can use this property to reorder the children.
{on} | off
Clipping mode. By default, MATLAB clips a uipanel's child axes, uipanels, and uibuttongroups to the uipanel rectangle. If you set Clipping to off, the axis, uipanel, or uibuttongroup is displayed outside the panel rectangle. This property does not affect child uicontrols which, by default, can display outside the panel rectangle.
string or function handle
Callback routine executed during object creation. The specified function executes when MATLAB creates a uipanel object. MATLAB sets all property values for the uipanel before executing the CreateFcn callback so these values are available to the callback. Within the function, use gcbo to get the handle of the uipanel being created.
Setting this property on an existing uipanel object has no effect.
You can define a default CreateFcn callback for all new uipanels. This default applies unless you override it by specifying a different CreateFcn callback when you call uipanel. For example, the code
set(0,'DefaultUipanelCreateFcn','set(gcbo,...
''FontName'',''arial'',''FontSize'',12)')creates a default CreateFcn callback that runs whenever you create a new panel. It sets the default font name and font size of the uipanel title.
Note Uibuttongroup takes its default property values from uipanel. Defining a default property for all uipanels defines the same default property for all uibuttongroups. |
To override this default and create a panel whose FontName and FontSize properties are set to different values, call uipanel with code similar to
hpt = uipanel(...,'CreateFcn','set(gcbo,... ''FontName'',''times'',''FontSize'',14)')
Note To override a default CreateFcn callback you must provide a new callback and not just provide different values for the specified properties. This is because the CreateFcn callback runs after the property values are set, and can override property values you have set explicitly in the uipushtool call. In the example above, if instead of redefining the CreateFcn property for this uipanel, you had explicitly set Fontsize to 14, the default CreateFcn callback would have set FontSize back to the system dependent default. |
Do not call copyobj or textwrap (which calls copyobj) inside a CreateFcn. The act of copying the uicontrol object fires the CreateFcn repeatedly, which raises a series of error messages after exceeding the root object's RecursionLimit property.
See Function Handle Callbacks for information on how to use function handles to define a callback function.
string or function handle
Callback routine executed during object deletion. A callback routine that executes when you delete the uipanel object (e.g., when you issue a delete command or clear the figure containing the uipanel). MATLAB executes the routine before destroying the object's properties so these values are available to the callback routine. The handle of the object whose DeleteFcn is being executed is accessible only through the root CallbackObject property, which you can query using gcbo.
{normal} | italic | oblique
Character slant used in the Title. MATLAB uses this property to select a font from those available on your particular system. Setting this property to italic or oblique selects a slanted version of the font, when it is available on your system.
string
Font family used in the Title. The name of the font in which to display the Title. To display and print properly, this must be a font that your system supports. The default font is system dependent. To eliminate the need to hard code the name of a fixed-width font, which may not display text properly on systems that do not use ASCII character encoding (such as in Japan), set FontName to the string FixedWidth (this string value is case insensitive).
set(uicontrol_handle,'FontName','FixedWidth')
This then uses the value of the root FixedWidthFontName property which can be set to the appropriate value for a locale from startup.m in the end user's environment. Setting the root FixedWidthFontName property causes an immediate update of the display to use the new font
integer
Title font size. A number specifying the size of the font in which to display the Title, in units determined by the FontUnits property. The default size is system dependent.
inches | centimeters | normalized | {points} |pixels
Title font size units. Normalized units interpret FontSize as a fraction of the height of the uipanel. When you resize the uipanel, MATLAB modifies the screen FontSize accordingly. pixels, inches, centimeters, and points are absolute units (1 point = 1/72 inch).
light | {normal} | demi | bold
Weight of characters in the title. MATLAB uses this property to select a font from those available on your particular system. Setting this property to bold causes MATLAB to use a bold version of the font, when it is available on your system.
ColorSpec
Color used for title font and 2-D border line. A three-element RGB vector or one of the MATLAB predefined names, specifying the font or line color. See the ColorSpec reference page for more information on specifying color.
{on} | callback | off
Control access to object's handle. This property determines when an object's handle is visible in its parent's list of children. When a handle is not visible in its parent's list of children, it is not returned by functions that obtain handles by searching the object hierarchy or querying handle properties. This includes get, findobj, gca, gcf, gco, newplot, cla, clf, and close. Neither is the handle visible in the parent figure's CurrentObject property. Handles that are hidden are still valid. If you know an object's handle, you can set and get its properties, and pass it to any function that operates on handles.
Handles are always visible when HandleVisibility is on.
Setting HandleVisibility to callback causes handles to be visible from within callback routines or functions invoked by callback routines, but not from within functions invoked from the command line. This provides a means to protect GUIs from command-line users, while allowing callback routines to have complete access to object handles.
Setting HandleVisibility to off makes handles invisible at all times. This may be necessary when a callback routine invokes a function that might potentially damage the GUI (such as evaluating a user-typed string), and so temporarily hides its own handles during the execution of that function.
You can set the root ShowHiddenHandles property to on to make all handles visible, regardless of their HandleVisibility settings. This does not affect the values of the HandleVisibility properties.
ColorSpec
3-D frame highlight color. A three-element RGB vector or one of the MATLAB predefined names, specifying the highlight color. See the ColorSpec reference page for more information on specifying color.
{on} | off
Callback routine interruption mode. If a callback is executing and the user triggers an event (such as a mouse click) on an object for which a callback is defined, that callback attempts to interrupt the first callback. MATLAB processes the callbacks according to these factors:
The Interruptible property of the object whose callback is executing
Whether the executing callback contains drawnow, figure, getframe, pause, or waitfor statements
The BusyAction property of the object whose callback is waiting to execute
If the Interruptible property of the object whose callback is executing is on (the default), the callback can be interrupted. Whenever the callback calls one of the drawnow, figure, getframe, pause, or waitfor functions, the function processes any events in the event queue, including the waiting callback, before performing its defined task.
If the Interruptible property of the object whose callback is executing is off, the callback cannot be interrupted (except by certain callbacks; see the note below). The BusyAction property of the object whose callback is waiting to execute determines what happens to the callback.
Note If the interrupting callback is a DeleteFcn or CreateFcn callback or a figure's CloseRequest or ResizeFcn callback, it interrupts an executing callback regardless of the value of that object's Interruptible property. The interrupting callback starts execution at the next drawnow, figure, getframe, pause, or waitfor statement. A figure's WindowButtonDownFcn callback routine, or an object's ButtonDownFcn or Callback routine are processed according to the rules described above. |
handle
Uipanel parent. The handle of the uipanel's parent figure, uipanel, or uibuttongroup. You can move a uipanel object to another figure, uipanel, or uibuttongroup by setting this property to the handle of the new parent.
position rectangle
Size and location of uipanel relative to parent. The rectangle defined by this property specifies the size and location of the panel within the parent figure window, uipanel, or uibuttongroup. Specify Position as
[left bottom width height]
left and bottom are the distance from the lower-left corner of the parent object to the lower-left corner of the uipanel object. width and height are the dimensions of the uipanel rectangle, including the title. All measurements are in units specified by the Units property.
string or function handle
Resize callback routine. MATLAB executes this callback routine whenever a user resizes the uipanel and the figure Resize property is set to on, or in GUIDE, the Resize behavior option is set to Other. You can query the uipanel Position property to determine its new size and position. During execution of the callback routine, the handle to the figure being resized is accessible only through the root CallbackObject property, which you can query using gcbo.
All axes, uipanel, uitable and uicontrol objects that have their Units set to normalized automatically resize proportionally to the figure. You can define individual resize functions for any such object as needed. For example, you can use ResizeFcn to maintain a GUI layout that is not directly supported by the MATLAB Position/Units paradigm.
For example, consider a GUI layout that maintains an object at a constant height in pixels and attached to the top of the figure, but always matches the width of the figure. The following ResizeFcn accomplishes this; it keeps the uicontrol whose Tag is 'StatusBar' 20 pixels high, as wide as the figure, and attached to the top of the figure. Note the use of the Tag property to retrieve the uicontrol handle, and the gcbo function to retrieve the figure handle. Also note the defensive programming regarding figure Units, which the callback requires to be in pixels in order to work correctly, but which the callback also restores to their previous value afterwards.
u = findobj('Tag','StatusBar');
fig = gcbo;
old_units = get(fig,'Units');
set(fig,'Units','pixels');
figpos = get(fig,'Position');
upos = [0, figpos(4) - 20, figpos(3), 20];
set(u,'Position',upos);
set(fig,'Units',old_units);You can change the figure Position from within a uipanel ResizeFcn callback; however, the ResizeFcn is not called again as a result.
A figure's uipanels resize before the figure itself does. Nested uipanels resize from inner to outer, with child ResizeFcns being called before parent ResizeFcns.
Note that the print command can cause the ResizeFcn to be called if the PaperPositionMode property is set to manual and you have defined a resize function. If you do not want your resize function called by print, set the PaperPositionMode to auto.
See Function Handle Callbacks for information on how to use function handles to define the callback function.
See Resize Behavior for information on creating resize functions using GUIDE.
on | off (read only)
Is object selected? This property indicates whether the panel is selected. When this property is on, MATLAB displays selection handles if the SelectionHighlight property is also on. You can, for example, define the ButtonDownFcn to set this property, allowing users to select the object with the mouse.
{on} | off
Object highlighted when selected. When the Selected property is on, MATLAB indicates the selected state by drawing four edge handles and four corner handles. When SelectionHighlight is off, MATLAB does not draw the handles.
ColorSpec
3-D frame shadow color. A three-element RGB vector or one of the MATLAB predefined names, specifying the shadow color. See the ColorSpec reference page for more information on specifying color.
string
User-specified object identifier. The Tag property provides a means to identify graphics objects with a user-specified label. You can define Tag as any string.
With the findobj function, you can locate an object with a given Tag property value. This saves you from defining object handles as global variables. For example, this function call returns the handles of all children (of the specified figures) that have the Tag value 'FormatTb'.
h = findobj(figurehandles,'Tag','FormatTb')
string
Title string. The text displayed in the panel title. You can position the title using the TitlePosition property.
If the string value is specified as a cell array of strings or padded string matrix, only the first string of a cell array or of a padded string matrix is displayed; the rest are ignored. Vertical slash ('|') characters are not interpreted as line breaks and instead show up in the text displayed in the uipanel title.
Setting a property value to default, remove, or factory produces the effect described in Defining Default Values. To set Title to one of these words, you must precede the word with the backslash character. For example,
hp = uipanel(...,'Title','\Default');
{lefttop} | centertop | righttop | leftbottom | centerbottom | rightbottom
Location of the title. This property determines the location of the title string, in relation to the uipanel.
string (read-only)
Object class. This property identifies the kind of graphics object. For uipanel objects, Type is always the string 'uipanel'.
handle
Associate a context menu with a uipanel. Assign this property the handle of a Uicontextmenu object. MATLAB displays the context menu whenever you right-click the uipanel. Use the uicontextmenu function to create the context menu.
inches | centimeters | {normalized} | points | pixels | characters
Units of measurement. MATLAB uses these units to interpret the Position property. For the panel itself, units are measured from the lower-left corner of the figure window. For children of the panel, they are measured from the lower-left corner of the panel.
Normalized units map the lower-left corner of the panel or figure window to (0,0) and the upper-right corner to (1.0,1.0).
pixels, inches, centimeters, and points are absolute units (1 point = 1/72 inch).
Character units are characters using the default system font; the width of one character is the width of the letter x, the height of one character is the distance between the baselines of two lines of text.
If you change the value of Units, it is good practice to return it to its default value after completing your computation so as not to affect other functions that assume Units is set to the default value.
matrix
User-specified data. Any data you want to associate with the uipanel object. MATLAB does not use this data, but you can access it using set and get.
{on} | off
Uipanel visibility. By default, a uipanel object is visible. When set to 'off', the uipanel is not visible, as are all child objects of the panel. When a panel is hidden in this manner, you can still query and set its properties.
Note The value of a uipanel's Visible property determines whether its child components, such as axes, buttons, uibuttongroups, and other uipanels, are visible. However, changing the Visible property of a panel does not change the settings of the Visible property of its child components even though hiding the panel causes them to be hidden. |
![]() | uipanel | uipushtool | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |