8144332: HSDB could not terminate when close button is pushed.
Reviewed-by: jbachorik
diff --git a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
index 97726c4..30d1f6b 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
@@ -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));