MATLAB Creating Graphical User Interfaces

(Barry) #1
Initialize a Programmatic UI

The fullfile function builds a full filename from parts.


The following statements start the Icon Editor application. The first statement creates a
new icon. The second statement opens existing icon file for editing.


cdata = iconEditor('iconwidth',16,'iconheight',25)
cdata = iconEditor('iconfile','eraser.gif');


iconEditor calls a routine, processUserIputs, during the initialization to accomplish
these tasks:



  • Identify each property by matching it to the first column of the cell array

  • Call the routine named in the second column to validate the input

  • Assign the value to the variable named in the third column


Make the Figure Invisible


When you create the figure window, make it invisible when you create it. Display it only
after you have added all the UI components.


To make the window invisible, set the figure Visible property to 'off' when you
create the figure:


hMainFigure = figure(...
'Units','characters',...
'MenuBar','none',...
'Toolbar','none',...
'Position',[71.8 34.7 106 36.15],...
'Visible','off');


After you have added all the components to the figure window, make the figure visible:


hMainFigure.Visible = 'on';


Most components have a Visible property. Thus, you can also use this property to make
individual components invisible.


Return Output to the User


If your program allows an output argument, and the user specifies such an argument,
then you want to return the expected output. The code that provides this output usually
appears just before the program’s main function returns.


In the example shown here,

Free download pdf