import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; public class Jutuklient3 extends Applet implements Runnable, ActionListener{ TextArea ta=new TextArea(); TextField tf=new TextField(); BufferedReader sisse; PrintWriter valja; public Jutuklient3(){ setLayout(new BorderLayout()); add(tf, BorderLayout.SOUTH); add(ta, BorderLayout.CENTER); tf.addActionListener(this); try{ Socket sc=new Socket("ws0.cs1.tpu.ee", 3001); sisse=new BufferedReader(new InputStreamReader(sc.getInputStream())); valja=new PrintWriter(sc.getOutputStream(), true); }catch(Exception e){} new Thread(this).start(); } public void actionPerformed(ActionEvent e){ valja.println("Jaagup: "+tf.getText()); tf.setText(""); } public void run(){ try{ while(true){ ta.append(sisse.readLine()+"\n"); } }catch(Exception e){} } public static void main(String argumendid[]){ Frame f=new Frame("Ruudu joonistamine"); f.setSize(300, 300); f.add(new Jutuklient3()); f.setVisible(true); } }