MATLAB Creating Graphical User Interfaces

(ff) #1
'Value',1 selects the radio button by default. Set the Value property to be the value of
the Max property to select the radio button. Set the value to be the value of the Min
property to deselect the radio button. The default values of Max and Min are 1 and 0,
respectively.

'Position',[30 20 150 20] specifies the location and size of the radio button. In this
example, the radio button is 150 pixels wide and 20 high. It is positioned 30 pixels from
the left of the figure and 20 pixels from the bottom.

Toggle Button

This code creates a toggle button:

f = figure;
tb = uicontrol(f,'Style','togglebutton',...
'String','Left/Right Tile',...
'Value',0,'Position',[30 20 100 30]);

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','togglebutton', specify the uicontrol to be
a toggle button.

'String','Left/Right Tile' puts a text label on the toggle button.

The 'Value',0 deselects the toggle button by default. To select (raise) the toggle button,
set Value equal to the Max property. To deselect the toggle button, set Value equal to
the Min property. By default, Min = 0 and Max = 1.

9 Lay Out a Programmatic UI

Free download pdf