Dispaying a dialog in the background.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Dispaying a dialog in the background.

  1. #1
    Join Date
    May 2004
    Posts
    3

    Unhappy Dispaying a dialog in the background.

    Hi,

    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:

    Code:
    /* Assume my frame's class is MyFrame, derived from JFrame */
     
    if(getFrameStatus() != MyFrame.ACTIVE)
    {
      oDialog.displayInBackground();
    }
    else
    {
      oDialog.displayInForeground();
    }
    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.

    Thanks,

    Shefali.

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    download TweakUI for windows/windowsxp from Microsoft, and put a tick in the box "Prevent applications stealing the focus"
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  3. #3
    Join Date
    May 2004
    Posts
    3
    Hi,

    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?

    Thanks,

    Shefali

  4. #4
    Join Date
    Feb 2004
    Posts
    808
    heh, yeah.. more like this:

    if(window is active)
    display dialog
    else
    queue dialog for display


    on event mainframe_got_focus
    if queue of dialogs has length > 0
    show dialogs..


    --

    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..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  5. #5
    Join Date
    May 2004
    Posts
    3
    Hi,

    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???

    Thanks,

    Shefali

  6. #6
    Join Date
    Feb 2004
    Posts
    808
    http://java.sun.com/j2se/1.4.2/docs/...ec.html#ZOrder

    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:

    myDialog.setState(dlgParent.getState());

    conjecture though.. i havent tried.. but have a read of all of that document..
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center