import java.awt.Graphics; import javax.swing.JFrame; public class Eksam1 extends JFrame { int x1 = 0; int y1 = 0; int x2 = 0; int y2 = 0; int X = 0; int dx = 0; public static void main(String[] args) { new Eksam1(); } Eksam1() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 205); setResizable(false); show(); while (true) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } dx += 10; if (dx > 360) dx = 0; repaint(); } } public void paint(Graphics g) { g.clearRect(0, 0, 400, 205); for (X = 0; X < 360; X += 10) { x1 = X; x2 = x1 + 10; y1 = (int)(Math.sin(Math.toRadians(X + dx)) * 80 + 110); y2 = (int)(Math.sin(Math.toRadians(X + dx + 10)) * 80 + 110); g.drawLine(x1 + 10, y1, x2 + 10, y2); } } }