MATLAB: Are the GUI objects not displayed in the correct stacking order in MATLAB 7.0 (R14)

behinddisplayframeguiMATLABorderr14stackinguicontrol

I have created a GUI in MATLAB 7.0 (R14) that features a number of uicontrol objects stacked on top of each other. When I set the uicontrol properties after creating the uicontrols, the uicontrol objects are not displayed in the correct stacking order. The following example code produces an editable text box on top of a frame; however the frame is displayed above the text box:
h = [];
h(1) = figure;
h(2) = uicontrol;
h(3) = uicontrol;
h(4) = uicontrol;
set(h(2),...
'style','frame',...
'pos',[5 5 100 200])
set(h(3),...
'style','edit',...
'string','edit',...
'pos',[10 10 80 30])
set(h(4),...
'style','text',...
'string','text',...
'pos',[10 60 80 30])

Best Answer

This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that uicontrol objects are rendered when setting their properties after creation.
Currently, to work around this issue, try resetting the the stacking order to force the figure to refresh itself with the uicontrols displayed correctly. This is accomplished by issuing the following command:
set(gcf, 'children', get(gcf, 'children'))