Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Detecting a JDialog opening and closing

843806Mar 12 2009 — edited Dec 15 2009
Hey everyone,

This is a simple question, or at least, it should be :). I need a Timer to start when a JDialog opens and stop when it closes so a cute icon animation shows.

So far, I managed to detect when the window opens, but not when it closes. This code is at the JDialog constructor:
addWindowListener(new WindowAdapter()
        {
            @Override
            public void windowClosed(WindowEvent we)
            {
                System.out.println("\t\t\t\twindowClosed");
                busyIconTimer.stop();
            }

            @Override
            public void windowOpened(WindowEvent we)
            {
                System.out.println("\t\t\t\twindowOpened");
                busyIconTimer.start();
            }
        });
When I call "setVisible(true)", the windowClosed event is raised.
When I call "setVisible(false", no event is called whatsoever (tried all the events available).
Instead, if I call "mydialog.dispose()", the windowClosed event is called correctly.
But after this, if I call "setVisible(true)" again, the windowOpened isn't called.

Can anyone help me? :)

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2010
Added on Mar 12 2009
9 comments
2,512 views