diff options
author | Tzafrir Cohen <tzafrir@cohens.org.il> | 2013-12-04 10:50:36 +0200 |
---|---|---|
committer | Tzafrir Cohen <tzafrir@cohens.org.il> | 2013-12-04 10:50:36 +0200 |
commit | 3bbbd95c8d2d6f3185b0f3e48263f36ba4bb0e75 (patch) | |
tree | b336db15d08ab911658a646a6b7f3e6bf011be28 /src/Client/UserInterface.java | |
parent | d57f9416a9d4bb92d4111f73af278f607bbe78b9 (diff) |
Convert source to NL-terminated
Diffstat (limited to 'src/Client/UserInterface.java')
-rw-r--r-- | src/Client/UserInterface.java | 246 |
1 files changed, 123 insertions, 123 deletions
diff --git a/src/Client/UserInterface.java b/src/Client/UserInterface.java index 20b235c..882534f 100644 --- a/src/Client/UserInterface.java +++ b/src/Client/UserInterface.java @@ -1,123 +1,123 @@ -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;
- private ChatClient client;
- private ChatClientReader read;
- private JTextField host = new JTextField("localhost", 15);
- private JTextField port = new JTextField("6667", 4);
-
- public void outputWriter (String line)
- {
- output.append(line + "\n");
- }
-
- /** Graphic interface recipient the client*/
- public UserInterface(ChatClient client)
- {
- this.client = client;
-
- 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(host);
- conPanel.add(new JLabel("port:"));
- conPanel.add(port);
-
- 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")
- {
- 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 )
- {
- if (client.connect("localhost",(Integer.parseInt("6667"))))
- {
- output.append("You've connect to the server succesufully" + "\n");
- counterClick++;
- }
- }
-
- }
-}
+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; + private ChatClient client; + private ChatClientReader read; + private JTextField host = new JTextField("localhost", 15); + private JTextField port = new JTextField("6667", 4); + + public void outputWriter (String line) + { + output.append(line + "\n"); + } + + /** Graphic interface recipient the client*/ + public UserInterface(ChatClient client) + { + this.client = client; + + 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(host); + conPanel.add(new JLabel("port:")); + conPanel.add(port); + + 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") + { + 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 ) + { + if (client.connect("localhost",(Integer.parseInt("6667")))) + { + output.append("You've connect to the server succesufully" + "\n"); + counterClick++; + } + } + + } +} |