diff --git a/src/client/Client1.java b/src/client/Client1.java index fba7c0d..bfce9ee 100644 --- a/src/client/Client1.java +++ b/src/client/Client1.java @@ -24,12 +24,11 @@ import java.awt.event.ActionEvent; * @version 0.1.3 * @author berdan */ - public class Client1 extends JFrame { - /** - * Hier werden Objekte und Variablen deklariert, damit diese in allen - * Methoden genutzt werden können. + /* + Hier werden Objekte und Variablen deklariert, damit diese + in allen Methoden genutzt werden können. */ private static JPanel contentPane; JTextField txtMessage; @@ -46,13 +45,10 @@ public class Client1 extends JFrame { public static int anzahlVersuche = 0; //Ist gleich die AN public static int anzahlRekursionen = 0; public static Message temp = new Message("leer", "leer"); - - /** - * In der main Methode wird das GUI erstellt und die start() Methode - * aufgerufen. - * - * @param args - * @throws InterruptedException + + /* + In der main Methode wird das GUI erstellt und die + start() Methode aufgerufen. */ public static void main(String[] args) throws InterruptedException { t1 = new Client1(); @@ -69,16 +65,20 @@ public class Client1 extends JFrame { try { start(); - } catch (ClassNotFoundException | IOException e) { + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block e.printStackTrace(); } } - /** - * In der Methode Client1() wird das GUI und die Befehle die durch einen - * Click des Button's ausgelöst werden festgelegt (Konstruktur) + /* + In der Methode Client1() wird das GUI + und die Befehle die durch einen Click des + Button's ausgelöst werden festgelegt */ - public Client1() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); @@ -125,10 +125,12 @@ public class Client1 extends JFrame { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); try { - oboust.writeObject(tosend); - oboust.flush(); - } catch (IOException e) { - e.printStackTrace(); + try { + oboust.writeObject(tosend); + oboust.flush(); + } catch (IOException e) { + e.printStackTrace(); + } } catch (Exception k) { print("KEINE VERBINDUNG"); } @@ -136,8 +138,9 @@ public class Client1 extends JFrame { if (temp.getMessage().equals("exit")) { System.exit(0); } + txtMessage.setText(""); - + } } @@ -149,6 +152,7 @@ public class Client1 extends JFrame { /** * Hier wird die textArea, auf welcher der Text ausgegeben wird * initialisiert + * */ textArea = new JTextArea(currentText); textArea.setLineWrap(true); @@ -162,6 +166,7 @@ public class Client1 extends JFrame { * wird, wodurch er nicht veränderlich ist. Außerdem wird die globale * Variabel j von 0 auf 1 gestzt, wodurch die start-Methode weiß, dass * sie eine Verbindung aufbauen soll. + * */ JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { @@ -181,8 +186,6 @@ public class Client1 extends JFrame { /** * In der Print-Methode wird der neue Text (also eine neue Nachricht) auf * die textArea abgebildet. - * - * @param neuerText */ public static void print(String neuerText) { currentText = neuerText + "\n" + currentText; @@ -201,9 +204,6 @@ public class Client1 extends JFrame { * * Es wird im Sekundentakt nach einer neuen Verbindung gesucht. * - * @throws IOException - * @throws ClassNotFoundException - * @throws InterruptedException */ public static void start() throws IOException, ClassNotFoundException, InterruptedException { @@ -221,14 +221,12 @@ public class Client1 extends JFrame { print("VERBINDUNG HERGESTELLT"); } catch (Exception KeineSocket) { print("SERVER ANTWORTET NICHT"); - try { Thread.sleep(5000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } - anzahlRekursionen++; if (anzahlRekursionen == 10) { print("KEINE ANTWORT, CLIENT WIRD BEENDET"); @@ -256,8 +254,8 @@ public class Client1 extends JFrame { * Benutzer über das GUI sendet "exit" lautet. * */ - while (!temp.getMessage().equals("exit")) { + //System.out.println("WHILE"); try { //System.out.println("hile4"); System.out.println("Nachricht erhalten");