8144332: HSDB could not terminate when close button is pushed.
authorysuenaga
Wed, 09 Dec 2015 21:24:57 +0900
changeset 35045 d7725e7f76b1
parent 35044 b4013c3f6807
child 35046 a5ade0cccbd4
child 35047 b1f924d2efe8
8144332: HSDB could not terminate when close button is pushed. Reviewed-by: jbachorik
hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Wed Dec 09 23:17:21 2015 +0900
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Wed Dec 09 21:24:57 2015 +0900
@@ -125,10 +125,14 @@
     }
   }
 
-  // close this tool without calling System.exit
-  protected void closeUI() {
-      workerThread.shutdown();
-      frame.dispose();
+  private class CloseUI extends WindowAdapter {
+
+      @Override
+      public void windowClosing(WindowEvent e) {
+          workerThread.shutdown();
+          frame.dispose();
+      }
+
   }
 
   public void run() {
@@ -144,7 +148,8 @@
 
     frame = new JFrame("HSDB - HotSpot Debugger");
     frame.setSize(800, 600);
-    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+    frame.addWindowListener(new CloseUI());
 
     JMenuBar menuBar = new JMenuBar();
 
@@ -207,7 +212,8 @@
     item = createMenuItem("Exit",
                             new ActionListener() {
                                 public void actionPerformed(ActionEvent e) {
-                                  closeUI();
+                                  workerThread.shutdown();
+                                  frame.dispose();
                                 }
                               });
     item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));