We are trying to save the state of the application on exit and restore it on startup. Part of the state is the relative Z-order of all JFrames.
Unfortunately, Swing doesn't seem to provide any method to learn or set Z-order of a Window (even relative to other windows in the same VM).
We deal with setting the Z-order by calling toFront() on all windows in successive order. But querying Z-order remains unsolved. (Adding focus listeners doesn't work always, for example, when one uses Windows' "Cascade" action on a group of windows.)
Any ideas?
JavaFX new fixes will continue to be supported on Java SE 8 through March 2022 and removed from Java SE 11. Swing and AWT will continue to be supported on Java SE 8 through at least March 2025, and on Java SE 11 (18.9 LTS) through at least September 2026.
The Swing Application Framework (JSR 296) is a Java specification for a simple application framework for Swing applications, with a graphical user interface (GUI) in computer software. It defines infrastructure common to most desktop applications, making Swing applications easier to create.
Java Swing is a lightweight Java graphical user interface (GUI) widget toolkit that includes a rich set of widgets. It is part of the Java Foundation Classes (JFC) and includes several packages for developing rich desktop applications in Java.
Swing API is a set of extensible GUI Components to ease the developer's life to create JAVA based Front End/GUI Applications. It is build on top of AWT API and acts as a replacement of AWT API, since it has almost every control corresponding to AWT controls.
Not with any granularity.
As you say, you can call toFront() and toBack(), and you can ask a window to "stay on top", but that's pretty much it.
Another option is to have a frame with internal frames, and use setComponentZOrder() (this only works for internal components though-- you have to call it on the container).
I believe one of the reasons for it not having been a priority in Swing is that support for Z-ordering is quite platform-dependent. (But hey, what isn't...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With