summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordor <dor1_b@walla.com>2014-03-15 10:47:49 +0200
committerTzafrir Cohen <tzafrir@cohens.org.il>2014-03-16 03:06:05 +0200
commit13f837f5d65274362fd6f99138a07cd3b9e0a1b6 (patch)
treeb7b64f90049953a5924e96748bcf4a52fce9de0a
parent6e7c77e22283459834aea09b870418decc266450 (diff)
UI : socket now closed when window closing in any way.
-rw-r--r--src/Client/UserInterface.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/Client/UserInterface.java b/src/Client/UserInterface.java
index cfa03b2..594bddf 100644
--- a/src/Client/UserInterface.java
+++ b/src/Client/UserInterface.java
@@ -6,6 +6,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@@ -16,7 +18,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
-public class UserInterface extends JFrame implements ActionListener, KeyListener
+public class UserInterface extends JFrame implements ActionListener, KeyListener, WindowListener
{
private JTextField message;
@@ -127,6 +129,8 @@ public class UserInterface extends JFrame implements ActionListener, KeyListener
add(vertPanel);
setVisible(true);
+
+ this.addWindowListener(this);
}
int counterClick = 0;
@@ -183,8 +187,34 @@ public class UserInterface extends JFrame implements ActionListener, KeyListener
}
}
-
+
+ public void windowClosing(WindowEvent e)
+ {
+ client.shutdown();
+ System.exit(0);
+ }
+
public void keyReleased(KeyEvent arg0) {}
public void keyTyped(KeyEvent arg0) {}
+
+ @Override
+ public void windowActivated(WindowEvent arg0){}
+
+ @Override
+ public void windowClosed(WindowEvent arg0){}
+
+ @Override
+ public void windowDeactivated(WindowEvent arg0){}
+
+ @Override
+ public void windowDeiconified(WindowEvent arg0){}
+
+
+ @Override
+ public void windowIconified(WindowEvent arg0){}
+
+ @Override
+ public void windowOpened(WindowEvent arg0){}
+
}