[ materofdeathejo @ 29.10.2014. 21:19 ] @
Kada kopiram ovaj kod u eclipse i pokrenem ga uvjek dobijem can not locate source file ... Sta treba da uradim .... Code: import java.applet.*; import java.awt.*; public class Zadatak2 extends Applet { int duzina, sirina; int dx, dy, xp, yp; int x1, y1, x2, y2; int click=0; int brp; public void init() { resize(500, 500); brp = Integer.parseInt(getParameter("brp")); } public boolean mouseDown(Event e, int x, int y) { if (click==0) { x1 = x; y1 = y; click++; }else { x2 = x; y2 = y; repaint(); click=0; } return true; } public void paint(Graphics g) { dx=Math.abs(x2-x1); dy=Math.abs(y2-y1); int ax=dx/(brp-1); int bx=dx/(brp*2-2); int ay=dy/(brp-1); int by=dy/(brp*2-2); if (x2>x1 && y2>y1) for (int i=0; i<brp; i++) g.drawRect(x1-bx+i*ax, y1-by+i*ay, ax, ay); else if (x2>x1 && y1>y2) for (int i=0; i<brp; i++) g.drawRect(x1-bx+i*ax, y1-by-i*ay, ax, ay); else if (x1>x2 && y2>y1) for (int i=0; i<brp; i++) g.drawRect(x1-bx-i*ax, y1-by+i*ay, ax, ay); else for (int i=0; i<brp; i++) g.drawRect(x1-bx-i*ax, y1-by-i*ay, ax, ay); g.drawLine(x1, y1, x2, y2); } } |