summaryrefslogtreecommitdiff
path: root/src/Client/UserInterface.java
diff options
context:
space:
mode:
authorDor Bivas <dor1_b@walla.com>2013-12-01 13:55:29 +0200
committerDor Bivas <dor1_b@walla.com>2013-12-01 13:55:29 +0200
commitc7876de55daeb34fb7f997aedcd30ce2b36c400d (patch)
treed5b66abc9b6827553afcd6855f5883114b51edf4 /src/Client/UserInterface.java
parentad5ae2ef8bc7a37050e79b20358334e6a52d6d68 (diff)
Note all the project and task 1-4
Diffstat (limited to 'src/Client/UserInterface.java')
-rw-r--r--src/Client/UserInterface.java116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/Client/UserInterface.java b/src/Client/UserInterface.java
new file mode 100644
index 0000000..1bf659e
--- /dev/null
+++ b/src/Client/UserInterface.java
@@ -0,0 +1,116 @@
+package Client;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.xml.soap.Text;
+
+public class UserInterface extends JFrame implements ActionListener
+{
+ private JTextField message;
+ private JTextArea output;
+
+ /** Running graphic interface */
+ public static void main(String args[])
+ {
+ new UserInterface();
+ }
+
+ /** Graphic interface recipient the client*/
+ public UserInterface()
+ {
+ this.setIconImage(getIconImage());
+ this.setSize(800, 400);
+
+ output = new JTextArea(10, 20);
+ output.setBackground(Color.gray);
+
+ JPanel msgPanel = new JPanel();
+ JPanel conPanel = new JPanel();
+ JPanel vertPanel = new JPanel();
+
+ message = new JTextField(40);
+ JButton stop = new JButton("Stop");
+ stop.setActionCommand("stop");
+ stop.addActionListener(this);
+ stop.setToolTipText("Click this button to exit.");
+
+ JButton send = new JButton("Send");
+ send.setActionCommand("send");
+ send.addActionListener(this);
+ send.setToolTipText("Click this button to send message.");
+
+ JButton connect = new JButton("Connect");
+ connect.setActionCommand("connect");
+ connect.addActionListener(this);
+ connect.setToolTipText("Click this button to connect the server.");
+
+ vertPanel.setLayout(new BoxLayout(vertPanel, BoxLayout.PAGE_AXIS));
+
+ msgPanel.add(connect);
+ msgPanel.add(send);
+ msgPanel.add(new JLabel("Message:"));
+ msgPanel.add(message);
+ msgPanel.add(stop);
+
+ conPanel.add(new JLabel("host:"));
+ conPanel.add(new JTextField("localhost", 15));
+ conPanel.add(new JLabel("port:"));
+ conPanel.add(new JTextField("6667", 4));
+
+ vertPanel.add(output);
+ vertPanel.add(conPanel);
+ vertPanel.add(msgPanel);
+
+ add(vertPanel);
+
+ setVisible(true);
+ }
+
+ /** Syncing the the action that the button send to the perform
+ * @param name of the action */
+ int counterClick = 0;
+ public void actionPerformed(ActionEvent e)
+ {
+
+ System.out.println(e.getActionCommand()); //FIXME: delete.
+ String command = e.getActionCommand();
+
+ if (command == "stop")
+ {
+ System.exit(0);
+ }
+
+ if (command == "send")
+ {
+ System.out.println(message.getText());
+ output.append(message.getText() + "\n");
+ message.setText("");
+ }
+
+ if (counterClick>0 && command == "connect")
+ {
+ output.append("You've connected to the server alredy" + "\n");
+ }
+
+ if (command == "connect" && counterClick == 0 )
+ {
+ output.append("You've connect to the server succesufully" + "\n");
+ counterClick++;
+ }
+
+
+
+// public void run ()
+// {
+//
+// }
+ }
+}