Resize the Window and Panel
By default, GUIDE UIs cannot be resized, but you can override this behavior by selecting
Tools > GUI Options and setting Resize behavior to Proportional.
Programmatic UIs can be resized by default, and you can change this behavior by setting
the Resize property of the figure on or off.
When the UI window is resizable, the position of components in the window adjust as the
user resizes it. If you have a panel in your UI, then the panel’s size will change with the
window’s size. Use the panel’s SizeChangedFcn callback to make your app perform
specific tasks when the panel resizes.
This code is an example of a panel’s SizeChangedFcn callback in a GUIDE app. When
the user resizes the window, this function modifies the font size of static text inside the
panel.
function uipanel1_SizeChangedFcn(hObject, eventdata, handles)
% hObject handle to uipanel1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(hObject,'Units','Points')
panelSizePts = get(hObject,'Position');
panelHeight = panelSizePts(4);
set(hObject,'Units','normalized');
newFontSize = 10 * panelHeight / 115;
texth = findobj('Tag','text1');
set(texth,'FontSize',newFontSize);
If your UI contains nested panels, then they will resize from the inside-out (in child-to-
parent order).
NoteTo make the text inside a panel resize automatically, set the fontUnits property to
'normalized'.
Button Group
Button groups are similar to panels, but they also manage exclusive selection of radio
buttons and toggle buttons. When a button group contains multiple radio buttons or
toggle buttons, the button group allows the end user to select only one of them.
Callbacks for Specific Components