Java 5 - Bring Modal Dialog to Front on any click - java

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.

Related

Java AWT Window management, user input, and focus?

I'm trying to hunt down the source of a bug that relates to window management, and possibly awt specifically. However, I have little to no familiarity with window management in general, or awt, so I'm even sure what I searching for. I'm hoping for some general guidance on terminology or otherwise that might help guide me in the correct direction.
In the program I am working on, the user can open windows that can be interacted with (i.e. they have text input boxes, drop down menus, etc) and windows that cannot be interacted with (i.e. they just display dialog). When the user opens a "non-interactive" window, the user can still use the underlying program. However, when an "interactive" window is opened, the user is blocked from using the underlying program until the window is closed. Additionally, "interactive" windows seem to stack themselves on top of "non-interactive" windows. That is to say, if I open a "non-interactive" window and then open an "interactive" window after, the "interactive" window will place itself on top of the "non-interactive" window and won't allow the user to use any of the title bar widgets. In this program, this behavior is not always desirable.
I assumed that this would have something to do with focusing, but I read through this document without much luck (this could be that I just don't know what I'm looking for). Particularly, I noticed the mention of "VetoableChangeLister" which doesn't seem to appear anywhere in the code I'm working with, as well as the method "requestFocusInWindow", which does appear in the code I'm working with but not in any way that I could see that relates to my above problem description.
Would the above problem be related to window focusing? Or am I barking up the wrong tree here? If nothing else, even some basic terminology so I can at least Google search intelligently.
The question I was asking relates to the "modality" of windows and was answered in the comments. The link provided explaining modality is https://docs.oracle.com/javase/tutorial/uiswing/misc/modality.html

How to keep taskbar bottom of other windows?

I try to make an application which must be full screen. But when i press CTRL+ALT+DEL task manager comes up. Even i disable task manager, at this time its error message comes up and make taskbar visible. Then user get the chance to go to the dekstop but i dont want user to get this chance. Only user could be able to go to desktop when it did what application wants from it. So i need taskbar keep bottom of other windows until user does what it should do. And i need to do this by my application which i try to code in Java
How can i change the status of task bar using registry?
Why not permanently disable the taskbar?
Follow this link to permanently disable the task bar.
You can edit .reg files in Java, follow This link to know how to edit .reg files
"But how can i do it by java without reseting the machine?"
As far as i came across, you have to reboot your system, no way out.
Ok i found it.
When i changed the value of 8th byte value of Settings variable to 10 in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2
in registery
It just deselect the "Keep the task bar on top other windows" option
For applying the changes explorer.exe should be killed and re run
There are key strokes which Windows catches before they are sent to application and Ctrl+Alt+Del is one of those.
Regarding "Then user get the chance to go to the dekstop", if you set frame.setAlwaysOnTop(true);, user won't be able to switch to other any application.
You can use java's fullscreen API, and then use a Robot to force focus back to your application. See here: Java Full Screen Program (Swing) -Tab/ALT F4.
Good luck in whatever you are doing - it doesn't sound fun!

Google WindowBuilder for Java

I made a GUI in Eclipse using the Google WindowBuilder plugin. The problem is that when I right-click on the design representation of my code and click, "Test/Preview," my GUI works and looks perfectly (the picture on the right), but when I click the "run" button in Eclipse to actually run the code, the GUI looks all weird (the picture on the left).
Does anybody have a clue as to what the problem is?
Ok this could have multiple reasons, the most obvious one being, that you (accidentally?) set your JButtons' background Color to the same dark-gray as your Frame's background. Check This first! WindowBuilder's preview has a quirk of sometimes not showing recent design changes on some elements immediately.
If that Is not the case with you, it might be some weird formatting thing.
Have you manually changed your buttons' formatting within the code and not within the design tab? Then add (Say your button is called okButton) okButton.repaint(); after the changes you manually made.
If this still doesnt work,
Try adding okButton.setVisible(true); (Althought that is pretty far fetched, seeing that a button outline can be seen!)

Screen capturing inactive window

Is it possible to get image contents of an obstructed window without bringing it to the front? Also, is it possible to send mouse clicks to a specific locations of such window? I want to do this in Java, using JNA, running Windows XP (if it is possible, would it also work on Windows 7?). If that can be done, would you mind telling me what functions will be needed and where can I read about it, because I have never worked with JNA yet. Thank you.

Display another modal dialog box on top of other modal dialog boxes in Java

I have a rather strange question:
I have a Java application which uses "applications" (plugins) run in different threads.
Most of these plugins will be written by other people and I will have no control over the code. The application requires a permanent connection to the Internet as information is constantly transferred between the server and app. What I want to do is have a thread which runs in the backround checking to see if there is a Internet connection. If the connection drops I want the ENTIRE application (and all its threads) to pause, display a message and when reconnected resume. I want this dialog box to be displayed above all other dialog boxes (modal or not). I'm thinking of something like the Windows Vista User Account Control Alerts.
How can I do this?
To solve this at all reasonably, you need to use Java 6, as previous versions simply don't give you the granularity of modality you need.
Here are the modality options.
For this to work effectively, you would have to have each plugin honor a contract to not use Toolkit modality (the default behavior is that a modal dialog box locks everything up, to keep backwards compatibility). Application modality would seem to be a great fit for you, but I don't see that you can implement this in Java. This seems to be up to the JVM vendor, as far as I could find.

Categories

Resources