MATLAB Creating Graphical User Interfaces

(Barry) #1

10 Lay Out a Programmatic UI


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','pushbutton', the uicontrol to be a push
button.

'String','Button 1' add the label, Button 1 to the push button.

'Position',[50 20 60 40] specifies the location and size of the push button. In this
example, the push button is 60 pixels wide and 40 high. It is positioned 50 pixels from
the left of the figure and 20 pixels from the bottom.

Displaying an Icon on a Push Button

To add an icon to a push button, assign the button's CData property to be an m-by-n-by-3
array of RGB values that define a truecolor image.

Radio Button

This code creates a radio button:

f = figure;
r = uicontrol(fh,'Style','radiobutton',...
Free download pdf