Results 1 to 7 of 7
  1. #1
    zenteo is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default How do I get all dialogs?

    How do I get all the visible dialogs created by my java application?

    It seems like "java.awt.Frame.getFrames()" didn't give me any of the dialogs, is there a "getDialogs" function?

    ~Zenteo
    Last edited by zenteo; 03-07-2010 at 05:17 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,192
    Rep Power
    19

    Default

    Use Window#getWindows() and iterate over the returned array testing for instanceof Dialog (or JDialog, if this is Swing). Depending on your specific requirements, it might be desirable to first invoke System#gc() to purge the array of Windows which are no longer reachable.

    But more important, why do you think you need this? There's probably a better way to do whatever it is you're doing.

    db

  3. #3
    zenteo is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    A little problem there;
    j2se doesn't have Window.getWindows() :/

    I'm trying to get the size and position of a dialog in the java application, Alice, using
    jython, which is integrated for scripting in Alice.

    Alice is a simple programming tool
    for beginners. You can create 3D games and animations with it.
    Alice.org if you're intrested.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by zenteo View Post
    A little problem there;
    j2se doesn't have Window.getWindows() :/
    Yes it does; similar to the Frame.getFrame() method; those methods are implemented in Java version 1.6.

    kind regards,

    Jos

  5. #5
    zenteo is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    Thanks for the replys :)
    Still, I get a "class 'java.awt.Window' has no attribute 'getWindows'" error from getWindow(), while
    getFrame() work like a charm... :(

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by zenteo View Post
    Thanks for the replys :)
    Still, I get a "class 'java.awt.Window' has no attribute 'getWindows'" error from getWindow(), while
    getFrame() work like a charm... :(
    Read the API documentation for those methods: getWindows() has only been with us since version 1.6 while Frames.getFrames() already existed in version 1.2

    kind regards,

    Jos

  7. #7
    zenteo is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    Ahh I see, Alice uses j2se 1.5.0.
    Thanks for the help though.

    Now, just tell me it's impossible or something : )

Similar Threads

  1. Passing data between dialogs
    By Wintery in forum New To Java
    Replies: 7
    Last Post: 01-02-2009, 05:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •