waitbar: java.awt.F​rame.getFr​ames() returning empty object on Matlab R2025b

34 views (last 30 days)
Dear all,
I've just installed Matlab R2025b on my machine, and I'm migrating all the scripts that I've developed from R2023b to R2025b, but I'm facing a problem when I try to create a waitbar always on top of other windows with R2025b.
With previous R2023b I've used following commands, and it always worked properly:
waitperc = 0;
f = waitbar(waitperc,'Processing, please wait...','windowstyle', 'modal');
frames = java.awt.Frame.getFrames();
frames(end).setAlwaysOnTop(1);
Instead, using same commands with R2025b following error appears on command window:
"Array indices must be positive integers or logical values."
The problem is that the object "frames" produced with R2025b is empty, while with R2023b consists of what is reported on figure below.
Please, can anyone help me to solve this problem?
Best regards,
Alberto

Answers (1)

dpb
dpb on 1 Oct 2025 at 15:56
Edited: dpb on 1 Oct 2025 at 21:43
In R2025a, Mathworks jumped with the theretofore threatened switch from the Java-based interface to the new desktop based on web technologies like JavaScript and HTML. Included in this massive redirection of technologies is that the Java runtime including the AWT is no longer distributed.
It is irrevocable that Mathworks is committed to the new desktop going forward. I would recommend <What's behind the new desktop> to get a viewpoint from the developer's perspective.
The Java frame doesn't exist in Javascript; see the <Recommendations for MATLAB Apps Using Jave>, the specific functionality is now unsupported for other than an uifigure Modal figures do appear on top although if an additional figure were to be created it would display.
For starters, I'd suggest just comment out the frame stuff and go on and see what the behavior is like; I do not know whether if one attempts to load the JRE whether such features would then be usable with the uifigure or not.(*)
I guess the Q? to ask that didn't is whether you are moving to the App Designer environment or continuing to try to migrate GUIDE-style figure apps?
(*) The ideal would be if simply creating the 'modal' waitbar does behave as you wish with the rest of the app; then you are done. If it still does end up occluded by something else, I think the first workaround would be to create a new uifigure with the 'WindowStyle','alwaysontop' and make the waitbar a child of it. I haven't tried this and don't have the inclination to try R2025x, so this is just postulation. The only apps I've built with AppDesigner do have a progress bar that does remain visible while all the work is done, but it also deactivates all the user controls during this time so nothing can happen to change focus in them. That may not be feasible for other apps.
  2 Comments
Alberto
Alberto on 2 Oct 2025 at 8:02
Finally I found a solution using "uiprogressdlg" in a figure, because is simpler and faster compared to managing the waitbar as a figure child. The example below works also on R2025b.
fig = uifigure('WindowStyle','alwaysontop');
scrsz = get(0,'ScreenSize');
scrcenter = [scrsz(3)/2 scrsz(4)/2];
fig_w = 400;
fig_h = 100;
fig.Position = [scrcenter(1)-fig_w/2 scrcenter(2)-fig_h/2 fig_w fig_h];
d = uiprogressdlg(fig);
d.ShowPercentage = 1;
d.Title = 'UI Progress test';
for i = 1 : 100
d.Value = i / 100;
pause(0.05);
end
close(fig);
However I'm so sad because, once again, Mathworks has introduced new features that break compatibility with previous versions due to deprecated commands, which is why switching from one Matlab release to the next is never easy. You can imagine the effort of someone like me managing a company's entire Model-Based Design toolchain...
For me the topic is closed.
dpb
dpb on 2 Oct 2025 at 13:24
Submit complaints and/or enhancement requests officially at <Product Support Page> in order for there to be any chance at all of them making changes in appearance and/or functionality. Answers isn't an official channel so complaints/suggestions posted here may or may not be seen and it's unlikely would ever get into the enhancement list otherwise.

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!