|
@ -1,12 +1,31 @@ |
|
|
import javax.swing.*; |
|
|
import javax.swing.*; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.net.Socket; |
|
|
|
|
|
|
|
|
public class ChatClient { |
|
|
public class ChatClient { |
|
|
private String address; |
|
|
private String address; |
|
|
public ChatClient() { |
|
|
|
|
|
|
|
|
private int port; |
|
|
|
|
|
private Socket connectionToServer; |
|
|
|
|
|
|
|
|
|
|
|
public ChatClient(int port) { |
|
|
|
|
|
this.port = port; |
|
|
address = JOptionPane.showInputDialog("bitte IP-Adresse"); |
|
|
address = JOptionPane.showInputDialog("bitte IP-Adresse"); |
|
|
|
|
|
|
|
|
|
|
|
if (address != null) { |
|
|
|
|
|
receiveMessages(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void receiveMessages() { |
|
|
|
|
|
try { |
|
|
|
|
|
connectionToServer = new Socket(address, port); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
JOptionPane.showMessageDialog(null, "Verbindung zum Server \"" + address + "\" fehlgeschlagen."); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
new ChatClient(); |
|
|
|
|
|
|
|
|
new ChatClient(3141); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |