import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.util.*; public class Jutugrklient2 extends Applet implements Runnable, MouseListener{ BufferedReader sisse; PrintWriter valja; public Jutugrklient2(){ try{ Socket sc=new Socket("ws0.cs1.tpu.ee", 3001); sisse=new BufferedReader(new InputStreamReader(sc.getInputStream())); valja=new PrintWriter(sc.getOutputStream(), true); addMouseListener(this); }catch(Exception e){} new Thread(this).start(); } public void mousePressed(MouseEvent e){ valja.println("jaagup "+e.getX()+" "+e.getY()); } public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void run(){ while(true){ try{ Graphics g=getGraphics(); String rida=sisse.readLine(); StringTokenizer stk=new StringTokenizer(rida); String kasutajanimi=stk.nextToken(); int x=Integer.parseInt(stk.nextToken()); int y=Integer.parseInt(stk.nextToken()); g.drawString(kasutajanimi, x, y); }catch(Exception e){} } } public static void main(String argumendid[]){ Frame f=new Frame("Graafiline jututuba"); f.setSize(300, 300); f.add(new Jutugrklient2()); f.setVisible(true); } }