Borrar filtros
Borrar filtros

How to make waitbar 'always on top'/bring to front

21 visualizaciones (últimos 30 días)
James Ramm
James Ramm el 5 de Abr. de 2011
Comentada: Markus Beschow el 13 de En. de 2023
Hi I have a GUI, which does some computation causing a waitbar to be displayed. This is fine. At some point, it brings up another waitbar, which causes the first waitbar to be 'pushed' to the back - i.e behind the main GUI. How can I keep the first waitbar 'always on top' - make sure that the main GUI is always kept to the back?

Respuestas (2)

Robert Cumming
Robert Cumming el 5 de Abr. de 2011
I thought this would be easy - but it took a bit more working out that I thought... I'm no expert in the Java side of matlab figures but this works for me (r2009b on Windows).
h=waitbar(0,'test','windowstyle', 'modal');
frames = java.awt.Frame.getFrames();
frames(end).setAlwaysOnTop(1);
for i=1:5
pause(0.5);
if i == 2
f = figure ( 'windowstyle', 'normal' );
set ( f, 'position', [300 300 600 400] );
plot ( sort(rand(10,1)), rand(10,1) );
end
waitbar(i/5,h);
end
close(f)
close(h)
  1 comentario
Markus Beschow
Markus Beschow el 13 de En. de 2023
Great solution! Also still works in r2020b on windows and probably should continue to work.
Does not disable interacting with matlab like the modal property does.

Iniciar sesión para comentar.


Jiro Doke
Jiro Doke el 5 de Abr. de 2011
Try setting the WindowStyle of the waitbar to modal:
h = waitbar(1, 'test', 'WindowStyle', 'modal');
  1 comentario
James Ramm
James Ramm el 15 de Abr. de 2011
This is a fairly good quick fix, but then the GUI is no longer running in the background, which could potentially be a problem...

Iniciar sesión para comentar.

Categorías

Más información sobre Dialog Boxes en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by