|
|
@ -2,12 +2,13 @@ import javax.swing.*; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.Socket; |
|
|
|
|
|
|
|
public class ChatClient { |
|
|
|
public class ChatClient extends JFrame { |
|
|
|
private String address; |
|
|
|
private int port; |
|
|
|
private Socket connectionToServer; |
|
|
|
|
|
|
|
|
|
|
|
public ChatClient(int port) { |
|
|
|
super("Chat"); |
|
|
|
this.port = port; |
|
|
|
address = JOptionPane.showInputDialog("bitte IP-Adresse"); |
|
|
|
|
|
|
@ -16,10 +17,18 @@ public class ChatClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void initGui() { |
|
|
|
setVisible(true); |
|
|
|
setSize(800, 600); |
|
|
|
setDefaultCloseOperation(EXIT_ON_CLOSE); |
|
|
|
} |
|
|
|
private void receiveMessages() { |
|
|
|
try { |
|
|
|
connectionToServer = new Socket(address, port); |
|
|
|
} catch (IOException e) { |
|
|
|
// Um GUI zu testen |
|
|
|
// Kommentar in der Zeile 28 wird weggenohmen, wenn der Server erstellt wird. |
|
|
|
// connectionToServer = new Socket(address, port); |
|
|
|
initGui(); |
|
|
|
} catch (Exception e) { |
|
|
|
JOptionPane.showMessageDialog(null, "Verbindung zum Server \"" + address + "\" fehlgeschlagen."); |
|
|
|
} |
|
|
|
} |
|
|
|