MATLAB: How to make a waitbar that is always on top of other windows

MATLAB

I have a waitbar that measures the progress of a script. However, the script causes other graphics objects to update, which brings them to the foreground and obscures the waitbar. Is there a way to ensure that it is always on top?

Best Answer

Please try to change 'WindowStyle' property of the waitbar Figure to 'modal'.
h=waitbar(0,'test','windowstyle', 'modal');
Also, you may be able to use some functionality provided by Java to accomplish this. Check out the solution available at the following MATLAB Central link:
Most importantly, the code necessary to set the waitbar to "always on top" is as follows:
h=waitbar(0,'test','windowstyle', 'modal');
frames = java.awt.Frame.getFrames();
frames(end).setAlwaysOnTop(1);