[ajug-members] Why doesn't this work?
Tim Watts
timtw at earthlink.net
Mon Oct 31 14:56:43 EST 2005
Thanks. Yeah, I saw that about 1/2 hr after I sent this out. DOH!
On Monday 31 October 2005 03:05, Jake wrote:
> Tim -
>
> method signatures are case sensative.. it's windowClosing not
> WindowClosing. so basically the adapter method you were trying to overwrite
> was never overwritten. i'd really rather not comment on the rest.
>
> - Jake Berner
> ----- Original Message -----
> From: Tim Watts
> To: ajug-members at ajug.org
> Sent: Monday, October 31, 2005 12:01 AM
> Subject: [ajug-members] Why doesn't this work?
>
>
> Can anyone see why this program can't hear any of the window events? I
> would expect that when I hit the [X] (close button) the System.out msg
> would appear on the console and the VM would terminate. But it goes
> completely unnoticed.
>
>
> package com.mycompany.swing;
>
>
> import java.awt.event.WindowAdapter;
>
> import java.awt.event.WindowEvent;
>
> import java.awt.event.WindowListener;
>
>
> import javax.swing.JApplet;
>
> import javax.swing.JFrame;
>
>
> public class WindowListenerTest extends JApplet
>
> {
>
> private JFrame frame;
>
>
> public WindowListenerTest()
>
> {
>
> buildGui();
>
> setListeners();
>
> frame.pack();
>
> frame.setVisible(true);
>
> }
>
> public static void main(String[] args)
>
> {
>
> javax.swing.SwingUtilities.invokeLater(new Runnable() {
>
> public void run() {
>
> new WindowListenerTest();
>
> }
>
> });
>
> }
>
> private void buildGui()
>
> {
>
> frame = new JFrame("Window Listener Test");
>
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>
> //frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
>
> frame.getContentPane().add(this);
>
> }
>
> private void setListeners() {
>
> frame.addWindowListener( new WindowAdapter() {
>
> public void WindowClosing(WindowEvent evt) {
>
> System.out.println("Shutting down...bye.");
>
> System.exit(0);
>
> }
>
> public void WindowGainedFocus(WindowEvent evt) {
>
> System.out.println("got focus.");
>
> }
>
> });
>
> WindowListener[] listeners = frame.getWindowListeners();
>
> System.out.println("listeners.length: " +listeners.length);
>
> }
>
> }
>
>
>
>
> ---------------------------------------------------------------------------
>---
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
More information about the ajug-members
mailing list