Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1229751

java doesn't exit when last frame exits

XMLWordPrintable

    • sparc
    • solaris_2.4, solaris_2.5

      The following simple program implements a simple Frame.
      When the user uses the window GUI to quit the Frame, the
      Frame goes away, but the Java interpreter is left hanging: it doesn't
      exit.

      I could call System.exit(0); from the event handler, but that then
      precludes the use of this frame in contexts where it might coexist
      with other frames ... It would be a bummer in that case if quitting a
      frame blew away the domain!

      import java.awt.*;

      public class Main extends Frame
      {
        public static void main(String[] args) {
          Main m = new Main();

          m.pack();
          m.show();
          m.resize(new Dimension(100, 100));
        }

        Main() {
          super("Test");
        }

        public boolean handleEvent(Event evt) {
          if (evt.id == Event.WINDOW_DESTROY)
            dispose();
          return false;
        }
      }

      The description field as copied from bug report 1232920 follows:


      The Frame class does not handle the Event.WINDOW_DESTROY event by
      default, which means that if the programmer does not explicitly subclass
      the Frame and handle this event specifically, nothing will happen when the
      user selects "Close" or "Quit" (in Solaris at least) off the window menu.

      By default, the Frame should handle this event in a reasonable way.

            amfowler Anne Fowler (Inactive)
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: