MATLAB Creating Graphical User Interfaces

(ff) #1
The first uicontrol argument, f, specifies the parent container. In this case, the parent
is a figure, but you can also specify the parent to be any container, such as a panel or
button group.

The name-value pair arguments, 'Style','text' specify the uicontrol to be static text.

'String','Select a set' specifies the text that displays. If you specify a component
width that is too small to accommodate all of the text, MATLAB wraps the text.

'Position',[30 50 130 30] specifies the location and size of the static text. In this
example, the static text is 130 pixels wide and 20 high. It is positioned 30 pixels from the
left of the figure and 50 pixels from the bottom.

Editable Text Field

This code creates an editable text field, txtbox:

f = figure;
txtbox = uicontrol(f,'Style','edit',...
'String','Enter your name here.',...
'Position',[30 50 130 20]);

9 Lay Out a Programmatic UI

Free download pdf