when I run an app in fullscreen an open a JFrame (for Settings), the Window of the app is minimized.
When I close the JFrame the app stays minimized and I habe to use Alt-Tab to get the window in Front again (or to maximize) again.
I don’t have this problem when I use the app in windowed mode.
Is there a command to bring the window of the app to the front again and give it the focus ?
This depends probably just on the windowing system you use and it might be tricky to affect how it works.
But just to get a clearer view, is the JFrame settings part of this same app? If so, I do recommend against this approach. Either a separate Swing settings or in-app settings with your UI lib of preference (Nifty, Lemur,…).
Mixing Swing/AWT with jME could cause some issues. Especially with LWJGL 3. Which you probably should be using.
thanks for the fast answer. Yes, I’m using several JFrame dialogs within JME and it works fine as long as the JME is windowed (see screenshot). Btw it’s not a game but a CAD-Software I’m writing.
JME in Windowed Mode: The JFrame opens and the JME stays visible in the back. When i close the JFrame the JME is in front. That’s fine (what you see in the pic).
JME in Fullscreen Mode: The JFrame opens and the JME minimizes. When I close the JFrame the JME stays minimized until I use Alt-Tab to get it back in fullscreen.
At the moment I dont’ have the time to change all Dialogs to nifty/lemur so if there isn’t an “easy” way to tell JME to maximaze again i will just keep the JME in windowed mode.
My programm already has about ~150 classes, ~20 dialogs and ~150.000 lines of Code. So it’s not so easy to make changes in a short time.
Maybe using jMECanvas would work then. But I also advice against this with the same reasoning. On LWJGL 2 this works at least. The Canvas approach would mean that your app is a basic Swing app and jME is just embedded in it.
As mentioned there are several issues with using JME with Swing. If you are targeting support for linux and macos, you will find the application will have major problems such as failing to launch and crashes. It is highly recommended to embed any UI directly into the application itself. As for the full screen issue, you are fighting Windows itself. One workaround would be to create the application as a windowed fullscreen app, but IIRC JME does not have that functionality but the underlying GLFW library that JME uses does have that functionality.
Note: regardless of JME, there are several issues with Java itself and window focus. You will find numerous articles on the web about this and getting a window to pop to the front AND have focus on all operating systems seems to be quite tricky.
I’m a big Java/Swing fanboy and this particular topic is particularly embarrassing to me.
I could not even make a simple 2D game platform (non-JME) for my daughter and I to work on a game that does this properly. On Linux, we still have to alt-tab away from and back to get key input to work… even after including 3 different work-arounds.
Hi @Edmundo, about windows with JavaSwing, if you are using the JFrames class for your dialogs, if so; it makes a lot of sense that they would, since JFrames are independent windows. I recommend you to use JDialog.
A JDialog will always stay in front of a JFrame, you can enable window passing to be able to interact with your JFrame and dialogs.