Dispaying a dialog in the background.
We have a requirement as follows: if the application frame is not the currently active frame (is hidden or minimized), then any dialog displayed for this application (error or a previously requested dialog) should be displayed in the background.
I tried calling .show() on the dialog, followed by a check for the frame's current state. If this state is not activated, then I call .toBack() on the dialog. But this causes a visible flicker which first shows the dialog on the current application and then hides the dialog. Is there any other way?
What I need is to somehow override the show() of the dialog to display in the background if the frame is not currently active... something like:
I DESPERATELY need help on this point, or I need to know that it cannot be done. Either way, a quick reply would be highly appreciated.
/* Assume my frame's class is MyFrame, derived from JFrame */
if(getFrameStatus() != MyFrame.ACTIVE)
download TweakUI for windows/windowsxp from Microsoft, and put a tick in the box "Prevent applications stealing the focus"
Thanks for the reply... But this is a window manager solution, and would only be applicable in windows... And I would have to make sure my client installed tweakUI in all machines... What I need is a Java solution... Any help there?
heh, yeah.. more like this:
if(window is active)
queue dialog for display
on event mainframe_got_focus
if queue of dialogs has length > 0
see, there's a bit of a problem here in that a JDialog is _designed_ to interrupt what the user is doing - youre after a JDialog that only interrupts if the application is focused, then you will probably have to create your own..
FINALLY someone understood exactly what I wanted! Thank god! I thought I've been speaking gibberish for so long!
Yes that is precisely what I want. I too have thought of the kind of solution you suggest of queuing dialogs, but that is kinda messy to code, and I wish to consider that as a last option thing...
And I know JDialog is written to interrupt whatever is being done. And hence I have already overridden the class, infact I have a semi modal dialog, as my application has multiple frames, and I want the dialog to only block its own parent frame, allowing other frames to continue working... Now I want this semimodal dialog to display behind other frames in the application if the parent frame is not currently displaying... Is there ANY way to override show to do this???
Seems to indicate that z-ordering and focus are implicitly linked on some systems and not on others.. You can certainly query a parent for its focused/active state and decide how the dialog is to be shown hence.. have a read of the document and see if you can come up with anything?
im thinking sort of along the lines of getting the parent's z-order, and setting the semimodal dialog to that order+1, then choosing whether it is to activate based on the state of the parent.. if setState(int) exists for te parent, it follows that int getState() might.. thus you could make your dialogs follow the parental state of activation by:
conjecture though.. i havent tried.. but have a read of all of that document..
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center