MATLAB: Is the string text displayed in the figure window have a different background color

MATLAB

The following simple routine exhibits blinking when displaying the string text on the screen.
fg=figure('units','normalized');
bgc=get(fg,'color');
uh=uicontrol(fg,'style','text','units','normalized','position',[0.1 0.3 0.3 0.1], ...
'string','TEST','backgroundcolor',bgc);
When the figure is displayed, the background of the text field turns to lighter gray
and then changes to background gray color. Is there any way to eliminate the display of light gray so that the texts are displayed without the screen blinking?

Best Answer

MATLAB uses the standard system background color of the system on which the GUI is running as the default component background color. This color varies on different computer systems, e.g., the standard shade of gray on the PC differs from that on UNIX, and may not match the default GUI background color. This appears to be causing the issue that you are facing.
To resolve the issue, use the following command at the start of your MATLAB session:
set(0,'defaultuicontrolBackgroundColor',get(0,'defaultFigureColor'))
For more information on setting the default properties of graphic objects, refer to the following documentation:
<http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/creating_plots/f7-21465.html>