diff options
author | Dor Bivas <dor1_b@walla.com> | 2013-12-04 17:04:09 +0200 |
---|---|---|
committer | Dor Bivas <dor1_b@walla.com> | 2013-12-04 17:04:09 +0200 |
commit | e534805201d41ad5005724ff33876b6818eb8024 (patch) | |
tree | ba505d16aa41f4cb4519aea4da1369143c78e5b2 /src/Client | |
parent | 1284776eee09318d98d438e10b30150dda47e272 (diff) |
Disabled connect bottun after 1 press
Diffstat (limited to 'src/Client')
-rw-r--r-- | src/Client/UserInterface.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/Client/UserInterface.java b/src/Client/UserInterface.java index 5f69550..38ada43 100644 --- a/src/Client/UserInterface.java +++ b/src/Client/UserInterface.java @@ -3,6 +3,7 @@ import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.AbstractButton; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; @@ -14,12 +15,15 @@ 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); + private JButton connect; + public void outputWriter (String line) { @@ -29,6 +33,7 @@ public class UserInterface extends JFrame implements ActionListener /** Graphic interface recipient the client*/ public UserInterface(ChatClient client) { + this.client = client; this.setIconImage(getIconImage()); @@ -51,15 +56,13 @@ public class UserInterface extends JFrame implements ActionListener send.setActionCommand("send"); send.addActionListener(this); send.setToolTipText("Click this button to send message."); - - JButton connect = new JButton("Connect"); + + this.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)); - - + vertPanel.setLayout(new BoxLayout(vertPanel, BoxLayout.PAGE_AXIS)); msgPanel.add(connect); msgPanel.add(send); @@ -67,8 +70,6 @@ public class UserInterface extends JFrame implements ActionListener msgPanel.add(message); msgPanel.add(stop); - - conPanel.add(new JLabel("host:")); conPanel.add(host); conPanel.add(new JLabel("port:")); @@ -84,13 +85,12 @@ public class UserInterface extends JFrame implements ActionListener } + int counterClick = 0; /** 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(); @@ -107,19 +107,16 @@ public class UserInterface extends JFrame implements ActionListener } - if (counterClick>0 && command == "connect") - { - output.append("You've alredy connected to the server" + "\n"); - } - if (command == "connect" && counterClick == 0 ) { if (client.connect("localhost",(Integer.parseInt("6667")))) { output.append("You've connect to the server succesufully" + "\n"); counterClick++; + this.connect.setEnabled(false); } } + } } |