Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Custom Fire a windowClosing event

521 views
Skip to first unread message

Frank Stillwell

unread,
Dec 9, 1999, 3:00:00 AM12/9/99
to
Hi,

I have a Frame that I have subclassed. When I click the "X" on the frame, I
can set the frame hidden by catching the windowClosing event in the Window
Adapter. I can also see this event occur if I instantiate the frame from
another class and set up a Window Listener on it.

Now, in addition to the "X" icon, I also have a "Close" button in the
subclassed frame. In the button's actionPerformed Actionevent handler, I
call my OnClose() routine (see below). When this happens, I also would like
a windowClosing event to fire, so other classes can determine that the
window is closing.

However, the code below is not accomplishing that, where I try to "manually"
fire the event. No event is seen in my other class (which *does* see an
event if I click the "X").

Ideas ? I tried it two different ways below, no luck.

private void onClose()


Event Windowclosing;
// Seems to be not working
java.awt.event.WindowEvent WINDOW_CLOSING; // Doesn't seem to work
either
this.setVisible(false);
// Window does disappear
}

Thanks in advance.progr

---
Frank


Dariusz Rakowicz

unread,
Dec 9, 1999, 3:00:00 AM12/9/99
to
Try
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
new WindowEvent(yourFrameRef, WindowEvent.WINDOW_CLOSING));

Dariusz.

Charlie Byrne

unread,
Dec 9, 1999, 3:00:00 AM12/9/99
to
processWindowEvent(new WindowEvent(this,WindowEvent.WINDOW_CLOSING));

Frank Stillwell <stil...@Adelphia.Net> wrote >

>
> However, the code below is not accomplishing that, where I try to
"manually"
> fire the event. No event is seen in my other class (which *does* see an
> event if I click the "X").
>
> Ideas ? I tried it two different ways below, no luck.
>
> private void onClose()
>
>
> Event Windowclosing;
> // Seems to be not working
> java.awt.event.WindowEvent WINDOW_CLOSING; // Doesn't seem to work
> either
> this.setVisible(false);
> // Window does disappear
> }
>
> Thanks in advance.
>

> ---
> Frank

--
Charlie Byrne * Delray Beach, FL * Mailto:CFB...@Adelphia.Net

0 new messages