I have an application that runs in fullscreen mode and has been working fine. Now I need to add a simple, undecorated dialog and I'm running into trouble. If I run the application maximized but not in fullscreen, the dialog displays and functions as expected. When I switch back to fullscreen, the dialog will not display.
The dialog extends JDialog and only contains a JSlider and a couple of buttons. It is undecorated and not modal. (I disabled modality for testing purposes -- it was a pain to force exit the app every time the dialog blocked input.) I'm entering full screen mode using setFullScreenWindow(), passing in the main JFrame for the app. It doesn't make a difference if I set that very JFrame as the owner of the JDialog or not. Nor does it seem to help if I call toFront() on the dialog.
The dialog seems to be active -- especially since it blocks input if I make it modal -- but just not showing or being hidden. So, is there any obvious trick to displaying a JDialog in fullscreen mode? Something I might be overlooking or omitting?
If there's no obvious solution, I can post some code later. Unfortunately, I don't have time right now.
JOptionPane.showInternalXXXDialog()
methods render dialogs as JInternalFrames.
Maybe you could consider using a JIternaFrame to simulate the dialog box.
And in fact, as M1EK alluded in his answer and I mentioned in a comment, Java applications in full screen mode will not allow other windows to show over them. The Javadoc API for GraphicsDevice reads:
Windows cannot overlap the full-screen window. All other application windows will always appear beneath the full-screen window in the Z-order.
In the end, I reconfigured my application so that it doesn't enter full screen mode until a bit later. This still gives me a fairly class presentation at the start and allows my JDialog to function as it should. The transition to full screen mode is quick and smooth, even in the "middle" of my app.
Do you really want to be in full-screen mode for this app? That's more of a gaming feature - to get more direct access to the frame-buffer, I always thought. Have you read this tutorial:
http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html
Really seems to me not to be the best choice for a Swing app with child windows.
Try to use this. Is not an exclusive full screen but it is close enough.
setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
Related
I need to drag windows that do not have keyboard focus on Windows 10 computers. Swing functions on my PC deny "mouse focus" on all windows in the same java application; they are locked out of being moved or uncovered for viewing.
The latest Swing dialog window controls the show; any other window that is needed for viewing (to help on answering the dialog) is unavailable when it is covered by another application window. On the Mac/OS X, mouse focus is not a problem; all windows seem to have it.
Is there a way to get this "mouse focus" on the PC when using the convenient modal Swing functions?
The 3 windows at issue in my application are:
Dialog: The latest Swing dialog hording all the mouse focus
Blocker: A JFrame or JDialog window that may or may not be an ancestor of Dialog but it is a big enough window to block view of Blockee
Blockee: The one that has information needed to answer the Dialog.
Only Dialog can be dragged on Windows 10 in this situation.
Is moving the information needed into the Dialog the only answer?
Are there windows 10 settings that can make it perform more sensibly?
I tried using different threads for Blockee and Blocker to no avail.
I found a fairly easy workaround for many cases: Identify the Blocker window and then take away its focusability (perhaps temporarily) when it might be a blocker and is no longer needed.
java.awt.Frame blocker = this; // or <parent> <grandparent>, etc.
blocker.setFocusable(false);
This does not make the Blocker or Blockee window moveable but it eliminates the problem by preventing the blocking. Maybe some day there will be a better solution for this in Windows 10.
I wanted to create an autoclicker that should have different functions. This autoclicker should have a JFrame in which you can make some configurations. I also wanted to offer a way to place the window "up". It should be possible to place the windows in a corner and it should also stay at the top when you are in a full screen. For example, if I am in a game, I want to be able to play the game as normal. While I'm playing the JFrame should stay above the game so I can see autoclickerframe. When I click on the window on which I can make settings, this should happen without the fullscreen window is reduced.
So my question is how this would be possible. I have seen "overlays" like this often already. Isn't overwolfs layout also working like my frame should? Is this even possible with java, if yes may one tell me how?
I need to do a loading window in java like this:
I tried with the jframe but I can't figure it out, I can't remove the close button, my jframe should look like a jpanel before that program begin, somebody know how to do this.
You Could...
Use Java's inbuild splash screen support. This is good as it gets loaded relatively earlier in the process by the JVM itself, so it comes up reasonably quick.
The major drawback (in my opinion) is it can be troublesome to get right as it doesn't follow the standard painting process that most developers are use to and you are going to have to paint it all yourself, there's no component support
How do I use SplashScreen without throwing a NullPointerException?
How to Undo the splash screen painting in java
Splash Screen Progress bar not drawing
You Could...
Create a JWindow. This is a frameless window, which won't appear on the taskbar (at least for some OSs).
You gain complete control over what and how things get displayed, as it's like dealing with any other window.
The only problem is that it won't become available for you to load until the JVM has completed loading your application. If the JVM needs to download resources over the network, for example, this could produce an undesirable delay
For example
Splashscreen in Java
SplashScreen java change alpha
Why won't this draw the image?
You Could...
Use an undecorated frame. This is pretty much the same as the JWindow option, except that a taskbar icon will be displayed, but on some OSs, this can't be completely helped.
See Frame#setUndecorated for more details
Final thoughts
Swing is not thread safe. So if you're displaying a splash screen, this means you should be ensuring that whatever actions you are taking are done off the Event Dispatching Thread, possibly through the use of SwingWorker
I'm trying to make a SWT-app that I'm building to minimize itself to it's tray-icon (i.e. a TrayItem in SWT). More specifically I want to achieve the following:
Both pressing close and minimize will minimize the app.
The app is not shown in the task-bar while it's minimized.
You can intercept window events in SWT quite easily.
Hiding apps from taskbar is something I haven't tried and I'd assume it requires calling some native function. I've found an example with taskbar which may be a starting point here .
Setting: Java 5 - no upgrade possible.
I have a large application that has a number of modal dialog windows. I have heard that hidden modal dialogs can result in uninformed users going so far as to restart their computer. Even if a user knows how to ALT-TAB (in MS Windows, at least), it's a pain. From what I understand, this was in part fixed in later versions of Java, but that's not an option here, unfortunately.
So, is there any way to force a modal dialog to be shown if any part of the running application is clicked on? I was thinking it might have something to do with either MouseListeners, GlassPanes, or something else. However, I've got a bunch of other stuff I'm supposed to be working on, so I don't have a lot of time to devote to hashing this out right now. Can anybody point me in the right direction?
Thanks so much!
So, is there any way to force a modal dialog to be shown if any part of the running application is clicked on?
When you create the dialog you need to specify the parent frame as the owner of the dialog. Then whenever you click on the frame any dialog that is a child will also be shown.