MATLAB Creating Graphical User Interfaces

(Barry) #1
Add Components to a Programmatic UI

'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]);


If the value of Max - Min is less than or equal to 1, the editable text field allows only a
single line of input. If the width of the text field is too narrow for the string, MATLAB
displays only part of the string. The user can use the arrow keys to move the cursor over
the entire string.

Free download pdf