“applet” class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import java.awt.*; import java.applet.*; public class applet extends Applet{ public void paint(Graphics g){ int total = 5; int x,y; Font font = new Font("Verdana", Font.BOLD, 42); Dimension d = getSize(); x=d.width;y=d.height/2; // create buildings int bw=d.width,by = d.height; int ar[] = {160,190,59,222,355,458,125} ; g.drawLine(x+34,y,x+60,y-25); g.drawLine(x+34,y,x+60,y-25); // while loop while(true){ g.setColor(Color.BLACK); bw=d.width; int i=0; while(bw>0){ // internal building creation g.drawLine(bw,by,bw,by-ar[i]); g.drawLine(bw-50,by,bw-50,by-ar[i]); g.drawLine(bw,by-ar[i],bw-50,by-ar[i]); int window = 10,height = by; while(height>0){ g.drawRect(bw-5,by,bw-35,height-15); height-=20; } bw-=50; if(i>4) i=0; else i++; } g.setFont(font); g.setColor(Color.WHITE); g.drawLine(x,y,x+100,y); g.drawLine(x,y+15,x+100,y+15); g.drawLine(x+100,y,x+100,y+15); //wing up g.drawLine(x+34,y,x+60,y-25); g.drawLine(x+44,y,x+70,y-25); g.drawLine(x+60,y-25,x+70,y-25); // wing down g.drawLine(x+34,y+15,x+60,y+25+15); g.drawLine(x+44,y+15,x+70,y+25+15); g.drawLine(x+60,y+25+15,x+70,y+25+15); // plane nose g.drawLine(x,y,x-10,y+7); g.drawLine(x,y+15,x-10,y+8); // plane end top g.drawLine(x+90,y,x+100,y-10); g.drawLine(x+100,y-10,x+100,y); try{ Thread.sleep(50); } catch(InterruptedException e){}; g.setColor(Color.GREEN); g.fillRect(0,0,d.width,d.height); g.setColor(Color.WHITE); if(x<=-100) x=d.width; else x-=5; } } } |
HTML File
1 |
<applet code='applet' width="800" height="400"></applet> |
How to Run
After compilation you can use “appletviewer” to run your applet.
appletviewer xyz.html