| Creating Graphical User Interfaces | ![]() |
You can control whether users can resize the figure window containing your GUI and how MATLAB handles resizing. GUIDE provides three options:
The first two approaches simply set properties appropriately and require no other action. User-specified resizing requires you to write a callback routine that recalculates sizes and positions of the components based on the new figure size. The following sections discuss each approach.
Certain types of GUIs are typically nonresizable. Warning and simple question dialog boxes, particularly modal windows, are usually not resizable. After a simple interaction, users dismiss these GUIs so changing their size is not necessary.
Property Settings. GUIDE sets the following properties to create nonresizable GUIs:
Units properties of the figure, axes, and uicontrols are set to characters (the Layout Editor default) so the GUI displays at the correct size on different computers.
Resize figure property is set to off.
ResizeFcn figure property is left unset.
Allowing Proportional GUI Resizing
Use this approach if you want to allow users to resize the GUI and are satisfied with a behavior that simply scales each component's size and relative position in proportion to the new figure size. Note that the font size of component labels does not resize and, if the size is reduced enough, these labels may become unreadable. This approach works well with simple GUI tools and dialog boxes that apply settings without closing.
Property Settings. GUIDE sets the following properties to create proportional resizing GUIs:
Units properties of the axes and uicontrols are set to normalized so that these components resize and reposition as the figure window changes size.
Units property of the figure is set to characters so the GUI displays at the correct size at run-time, based on any changes in font size.
Resize figure property set to on (the default).
ResizeFcn figure property is left unset.
User-Specified Resize Operation
You can create GUIs that accommodate resizing, while at the same time maintain the appearance and usability of your original design by programming the figure ResizeFcn callback routine. This callback routine allows you to recalculate the size and position of each component based on the new figure size.
This approach to handling figure resizing is used most typically in GUI-based applications that require user interaction on an ongoing basis. Such an application might contain axes for displaying data and various components whose position and size are critical to the successful use of the interface.
Property Settings. GUIDE sets the following properties to implement this style of GUI:
Units properties of the figure, axes, and UIcontrols are set to characters so the GUI displays at the correct size at run-time.
Resize figure property is set to on (the default).
ResizeFcn figure property requires a callback routine to handle resizing.
See The Address Book Resize Function for an example of a user-written resize function.
| Selecting GUI Options | Command-Line Accessibility | ![]() |