import java.net.*; import java.awt.event.*; import java.util.*; import java.awt.*; import java.applet.Applet; import java.io.*; import java.util.StringTokenizer; public class vork extends Applet implements MouseListener,Runnable{ BufferedReader sisse; PrintWriter valja; Socket sc; int sx1=-1; int sy1=-1; int sx2=-1; int sy2=-1; int x1=-1; int y1=-1; int x2=-1; int y2=-1; int olek=0; int a=-1; StringTokenizer st; public vork(){ try{ sc=new Socket("localhost", 4021); sisse=new BufferedReader(new InputStreamReader(sc.getInputStream())); valja=new PrintWriter(sc.getOutputStream(), true); } catch(Exception y){} new Thread(this).start(); addMouseListener(this); } public void paint (Graphics g){ if (olek==1){ valja.println(x1+" "+y1+" "+x2+" "+y2); g.drawLine(x1,y1,x2,y2); } g.drawLine(sx1,sy1,sx2,sy2); } public void mousePressed(MouseEvent e){ a++; if (a==0){ x1=e.getX(); y1=e.getY(); } if (a==1){ x2=e.getX(); y2=e.getY(); olek=1; paint(getGraphics()); a=-1; olek=0; } } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void run() { try{ boolean on=true; while(on){ String rida=sisse.readLine(); st=new StringTokenizer(rida, " "); sx1=Integer.parseInt(st.nextToken()); sy1=Integer.parseInt(st.nextToken()); sx2=Integer.parseInt(st.nextToken()); sy2=Integer.parseInt(st.nextToken()); System.out.println(sx1+"ee"+sy1+"ee"+sx2+"ee"+sy2); paint(getGraphics()); } }catch(Exception e){} } public static void main(String Argumendid[]){ Frame f=new Frame("Adobe Photoshop 9.0"); f.setSize(50*3+200,50*3+150); f.setResizable(false); f.add(new vork()); f.setVisible(true); f.addWindowListener(new akenkinni()); } } class akenkinni extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } }