Java Applet Drawing Spiral

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java Applet Drawing Spiral as PDF for free.

More details

  • Words: 111
  • Pages: 1
import import import public

java.awt.*; //required for programs that draw javax.swing.*; //required for Swing applets java.util.Random; class Linespiral extends JApplet {

public void paint(Graphics g) { super.paint(g); Random r=new Random(); g.setColor(Color.red); int k=1,x1=300,y1=300,x2=300,y2=305; for (int i=1;i<=26;i++) {g.setColor(new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256))); g.drawLine(x1,y1,x2,y2); x1=x2; y1=y2; x2=x2-5*k; k=k+1; for (int m=1;m<=70000000;m++); g.setColor(new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256))); g.drawLine(x1,y1,x2,y2); x1=x2; y1=y2; y2=y2-5*k; k=k+1; for (int m=1;m<=70000000;m++); g.setColor(new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256))); g.drawLine(x1,y1,x2,y2); x1=x2; y1=y2; x2=x2+5*k; k=k+1; for (int m=1;m<=70000000;m++); g.setColor(new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256))); g.drawLine(x1,y1,x2,y2); x1=x2; y1=y2; y2=y2+5*k; k=k+1; for (int m=1;m<=70000000;m++); } Dimension appletSize = super.getSize(); int appletHeight = appletSize.height; int appletWidth = appletSize.width; g.drawString("This applet is " + appletHeight + " pixels high by " + appletWidth + " pixels wide.", 15, appletHeight-10); } }

Related Documents

Java Applet
June 2020 2
Spiral
July 2020 15
Spiral
June 2020 14
Athipathy Applet
April 2020 16
Applet Browser
April 2020 8