changeset 8979:1ebcc366ee62

8144332: HSDB could not terminate when close button is pushed. Reviewed-by: jbachorik
author ysuenaga
date Wed, 09 Dec 2015 21:24:57 +0900
parents 7cbcb271bad7
children 894c78fcb2ea
files agent/src/share/classes/sun/jvm/hotspot/HSDB.java
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Tue Apr 30 17:42:33 2019 +0200
+++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Wed Dec 09 21:24:57 2015 +0900
@@ -128,10 +128,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() {
@@ -147,7 +151,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();
 
@@ -210,7 +215,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));