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','edit', specify the style of the uicontrol to
be an editable text field.


'String','Enter your name here', specifies the default text to display.


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


To enable multiple-line input, the value of Max - Min must be greater than 1, as in the
following statement.


txtbox = uicontrol(f,'Style','edit',...
'String','Enter your name and address here.',...
'Max',2,'Min',0,...
'Position',[30 20 130 80]);


Add Components to a Programmatic App
Free download pdf