|
@ -7,7 +7,6 @@ import java.net.Socket; |
|
|
|
|
|
|
|
|
public class ChatClient extends JFrame implements KeyListener { |
|
|
public class ChatClient extends JFrame implements KeyListener { |
|
|
private String address; |
|
|
private String address; |
|
|
private int port; |
|
|
|
|
|
private Socket connectionToServer; |
|
|
private Socket connectionToServer; |
|
|
private BufferedReader fromServerReader; |
|
|
private BufferedReader fromServerReader; |
|
|
private PrintWriter toServerWriter; |
|
|
private PrintWriter toServerWriter; |
|
@ -17,9 +16,8 @@ public class ChatClient extends JFrame implements KeyListener { |
|
|
private JTextField inputTextField; |
|
|
private JTextField inputTextField; |
|
|
private JScrollPane outputScrollPane; |
|
|
private JScrollPane outputScrollPane; |
|
|
|
|
|
|
|
|
public ChatClient(int port) { |
|
|
|
|
|
|
|
|
public ChatClient() { |
|
|
super("Chat"); |
|
|
super("Chat"); |
|
|
this.port = port; |
|
|
|
|
|
address = JOptionPane.showInputDialog("bitte IP-Adresse"); |
|
|
address = JOptionPane.showInputDialog("bitte IP-Adresse"); |
|
|
|
|
|
|
|
|
if (address != null) { |
|
|
if (address != null) { |
|
@ -48,7 +46,7 @@ public class ChatClient extends JFrame implements KeyListener { |
|
|
} |
|
|
} |
|
|
private void receiveMessages() { |
|
|
private void receiveMessages() { |
|
|
try { |
|
|
try { |
|
|
connectionToServer = new Socket(address, port); |
|
|
|
|
|
|
|
|
connectionToServer = new Socket(address, Constants.PORT); |
|
|
fromServerReader = new BufferedReader(new InputStreamReader(connectionToServer.getInputStream())); |
|
|
fromServerReader = new BufferedReader(new InputStreamReader(connectionToServer.getInputStream())); |
|
|
toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream())); |
|
|
toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream())); |
|
|
|
|
|
|
|
@ -108,6 +106,6 @@ public class ChatClient extends JFrame implements KeyListener { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
new ChatClient(3141); |
|
|
|
|
|
|
|
|
new ChatClient(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |