[ajug-members] preventing window close

John Wells jb at sourceillustrated.com
Thu Sep 16 08:37:56 EDT 2004


Guys,

Trying to prevent a JFrame from being closed.  I have the following code:

frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

frame.addWindowListener(new WindowAdapter(){
  public void windowClosing (WindowEvent e)
  {
    System.out.println("Can't close me!");
  }

  public void windowIconified(WindowEvent e)
  {
    System.out.println("I'm iconifying...");
  }
});

On both Windows and Linux, I'm able to see the windowIconified event, but
windowClosing never fires.  Is there an esoteric trick to doing this I'm
unaware of?

Thanks for the help.

John




More information about the ajug-members mailing list