summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDor Bivas <dor1_b@walla.com>2014-01-18 14:48:55 +0200
committerDor Bivas <dor1_b@walla.com>2014-01-18 14:48:55 +0200
commit2abe19f0946d571a784b93d66a54d5c686313aa5 (patch)
tree4a6d2bf2791124fea71eb642707095bd70a7c6fd
parent8e00afc1514660da67d45fa4e78905559747b637 (diff)
Enter key now sending message.
-rw-r--r--src/Client/UserInterface.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Client/UserInterface.java b/src/Client/UserInterface.java
index 02abbfd..abf5002 100644
--- a/src/Client/UserInterface.java
+++ b/src/Client/UserInterface.java
@@ -2,6 +2,8 @@ package Client;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
import java.net.Socket;
import javax.swing.AbstractButton;
@@ -15,7 +17,7 @@ import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.xml.soap.Text;
-public class UserInterface extends JFrame implements ActionListener
+public class UserInterface extends JFrame implements ActionListener, KeyListener
{
private JTextField message;
@@ -53,6 +55,7 @@ public class UserInterface extends JFrame implements ActionListener
JScrollPane scrollText = new JScrollPane(feedbackText);
message = new JTextField(40);
+ message.addKeyListener(this);
JButton stop = new JButton("Stop");
stop.setActionCommand("stop");
stop.addActionListener(this);
@@ -150,4 +153,19 @@ public class UserInterface extends JFrame implements ActionListener
}
+
+ @Override
+ public void keyPressed(KeyEvent e)
+ {
+ if (e.getKeyChar() == KeyEvent.VK_ENTER)
+ {
+ output.append(message.getText() + "\n");
+ client.PRIVMSG(message.getText());
+ message.setText("");
+ }
+ }
+
+ public void keyReleased(KeyEvent arg0) {}
+
+ public void keyTyped(KeyEvent arg0) {}
}