Lay Out a UI Programmatically
- The value of the axes width, axwidth, allows 50 pixels of space between the right side
of the axes and the right edge of the figure. In this calculation, the max function limits
this value to nonnegative values.
Notice that all the layout code is inside the resizeui function. It is a good practice to
put all the layout code inside the SizeChangedFcn callback to ensure the most accurate
results.
Also, it is important to delay the display of the entire UI window until after all the
variables that a SizeChangedFcn callback uses are defined. Doing so can prevent the
SizeChangedFcn callback from returning an error. To delay the display of the window,
set the Visible property of the figure to 'off'. After you define all the variables that
your SizeChangedFcn callback uses, set the Visible property to 'on'.
Manage the Stacking Order of Grouped Components
If your UI has components grouped inside of uipanels, uibuttongroups or uitabs, then you
might need to manage their front-to-back order, or stacking order, to make the UI look
the way you want. The default stacking order of components is as follows:
- Axes and other Graphics objects appear at the bottom.
- Other UI components appear in the order in which you create them. They can stack in
any order.
Use the Parent property to control the front-to-back order (stacking order) of grouped
components. To move a component on top of another component, set its Parent property
to the object you want to appear beneath it.
The Children property of a uipanel, uibuttongroup, or uitab lists the child objects inside
the container according to their stacking order.