import java.awt.Image;import java.awt.Font;import java.awt.FontMetrics;import java.awt.MediaTracker;import java.awt.Event;import java.awt.Graphics;import java.awt.Color;import java.net.URL;import java.net.MalformedURLException;import java.applet.AudioClip;public class test extends java.applet.Applet {int which, last_roll, repaint_needed=1;Image image1;boolean image_drawn1 = false; String string2 = "Help is on the way!!";Font font2 = new Font("TimesRoman", Font.ITALIC, 24);FontMetrics fm2;boolean text_drawn2 = false; Image image3;boolean image_drawn3 = false; Image image4;boolean image_drawn4 = false; String string5 = "Click & release to toggle help";Font font5 = new Font("TimesRoman", Font.BOLD, 12);FontMetrics fm5;boolean text_drawn5 = false; String string6 = "Click down to play sound";Font font6 = new Font("TimesRoman", Font.BOLD, 12);FontMetrics fm6;boolean text_drawn6 = false; String string7 = "Click & release to move to new page";Font font7 = new Font("TimesRoman", Font.BOLD, 12);FontMetrics fm7;boolean text_drawn7 = false; String string8 = "Click down to toggle image";Font font8 = new Font("TimesRoman", Font.BOLD, 12);FontMetrics fm8;boolean text_drawn8 = false; Image image9;Image image10;Image image11;Image image12;URL url13;AudioClip sound14;Image back15;boolean r1 = false;int ulx_1, uly_1, lrx_1, lry_1;boolean r2 = false;int ulx_2, uly_2, lrx_2, lry_2;boolean r3 = false;int ulx_3, uly_3, lrx_3, lry_3;boolean r4 = false;int ulx_4, uly_4, lrx_4, lry_4;boolean c1 = false;boolean t1 = false;int ulx_5, uly_5, lrx_5, lry_5;boolean t2 = false;boolean t3 = false;boolean c4 = false;boolean t4 = false;int ulx_6, uly_6, lrx_6, lry_6;public void init() {MediaTracker tracker = new MediaTracker(this);image1 = getImage(getCodeBase(), "btn2.gif");tracker.addImage(image1, 0);fm2 = getFontMetrics(font2);image3 = getImage(getCodeBase(), "btn2.gif");tracker.addImage(image3, 0);image4 = getImage(getCodeBase(), "picture.gif");tracker.addImage(image4, 0);fm5 = getFontMetrics(font5);fm6 = getFontMetrics(font6);fm7 = getFontMetrics(font7);fm8 = getFontMetrics(font8);image9 = getImage(getCodeBase(), "hlpbtn.gif");tracker.addImage(image9, 0);image10 = getImage(getCodeBase(), "sndbtn.gif");tracker.addImage(image10, 0);image11 = getImage(getCodeBase(), "urlbtn.gif");tracker.addImage(image11, 0);image12 = getImage(getCodeBase(), "gifbtn.gif");tracker.addImage(image12, 0);try { url13 = new URL("http://www.cs.utk.edu/~beck"); }catch (MalformedURLException e) { System.out.println("Bad URL: " + "http://www.cs.utk.edu/~beck");} sound14 = getAudioClip(getCodeBase(), "doh.au");back15 = getImage(getCodeBase(), "yy.gif");tracker.addImage(back15, 0);try {tracker.waitForAll();} catch(InterruptedException e) {System.out.println("Image loading failed");}tracker.checkAll(true);uly_1 = this.getSize().height;if (uly_1 > (70-fm8.getAscent()))uly_1 = 70-fm8.getAscent();ulx_1 = 20;uly_2 = this.getSize().height;if (uly_2 > (170-fm7.getAscent()))uly_2 = 170-fm7.getAscent();ulx_2 = 20;uly_3 = this.getSize().height;if (uly_3 > (70-fm6.getAscent()))uly_3 = 70-fm6.getAscent();ulx_3 = 240;uly_4 = this.getSize().height;if (uly_4 > (170-fm5.getAscent()))uly_4 = 170-fm5.getAscent();ulx_4 = 240;uly_5 = this.getSize().height;if (uly_5 > 20)uly_5 = 20;if (uly_5 > 20)uly_5 = 20;ulx_5 = 20;uly_6 = this.getSize().height;if (uly_6 > (100-fm2.getAscent()))uly_6 = 100-fm2.getAscent();if (uly_6 > 120)uly_6 = 120;ulx_6 = 100;lrx_1 = 0;lry_1 = 0;if (lrx_1 < (20 + fm8.stringWidth(string8))){lrx_1 = 20 + fm8.stringWidth(string8);}if (lry_1 < (70 + fm8.getDescent())){lry_1 = 70 + fm8.getDescent();}lrx_2 = 0;lry_2 = 0;if (lrx_2 < (20 + fm7.stringWidth(string7))){lrx_2 = 20 + fm7.stringWidth(string7);}if (lry_2 < (170 + fm7.getDescent())){lry_2 = 170 + fm7.getDescent();}lrx_3 = 0;lry_3 = 0;if (lrx_3 < (240 + fm6.stringWidth(string6))){lrx_3 = 240 + fm6.stringWidth(string6);}if (lry_3 < (70 + fm6.getDescent())){lry_3 = 70 + fm6.getDescent();}lrx_4 = 0;lry_4 = 0;if (lrx_4 < (240 + fm5.stringWidth(string5))){lrx_4 = 240 + fm5.stringWidth(string5);}if (lry_4 < (170 + fm5.getDescent())){lry_4 = 170 + fm5.getDescent();}lrx_5 = 0;lry_5 = 0;if (lrx_5 < (200 + image4.getWidth(this))){lrx_5 = 200 + image4.getWidth(this);}if (lry_5 < (20 + image4.getHeight(this))){lry_5 = 20 + image4.getHeight(this);}if (lrx_5 < (20 + image3.getWidth(this))){lrx_5 = 20 + image3.getWidth(this);}if (lry_5 < (20 + image3.getHeight(this))){lry_5 = 20 + image3.getHeight(this);}lrx_6 = 0;lry_6 = 0;if (lrx_6 < (100 + fm2.stringWidth(string2))){lrx_6 = 100 + fm2.stringWidth(string2);}if (lry_6 < (100 + fm2.getDescent())){lry_6 = 100 + fm2.getDescent();}if (lrx_6 < (240 + image1.getWidth(this))){lrx_6 = 240 + image1.getWidth(this);}if (lry_6 < (120 + image1.getHeight(this))){lry_6 = 120 + image1.getHeight(this);}}public boolean handleEvent(Event evt) {boolean in_1 = (evt.x > 240 && evt.x < (240 +image1.getWidth(this)) && evt. y > 120 && evt.y < (120 + image1.getHeight(this)));boolean in_2 = (evt.x > 100 && evt.x < (100 +fm2.stringWidth(string2)) && evt. y < 100 && evt.y > (100 - fm2.getHeight()));boolean in_3 = (evt.x > 20 && evt.x < (20 +image3.getWidth(this)) && evt. y > 20 && evt.y < (20 + image3.getHeight(this)));boolean in_4 = (evt.x > 200 && evt.x < (200 +image4.getWidth(this)) && evt. y > 20 && evt.y < (20 + image4.getHeight(this)));boolean in_5 = (evt.x > 240 && evt.x < (240 +fm5.stringWidth(string5)) && evt. y < 170 && evt.y > (170 - fm5.getHeight()));boolean in_6 = (evt.x > 240 && evt.x < (240 +fm6.stringWidth(string6)) && evt. y < 70 && evt.y > (70 - fm6.getHeight()));boolean in_7 = (evt.x > 20 && evt.x < (20 +fm7.stringWidth(string7)) && evt. y < 170 && evt.y > (170 - fm7.getHeight()));boolean in_8 = (evt.x > 20 && evt.x < (20 +fm8.stringWidth(string8)) && evt. y < 70 && evt.y > (70 - fm8.getHeight()));boolean in_9 = (evt.x > 240 && evt.x < (240 +image9.getWidth(this)) && evt. y > 120 && evt.y < (120 + image9.getHeight(this)));boolean in_10 = (evt.x > 240 && evt.x < (240 +image10.getWidth(this)) && evt. y > 20 && evt.y < (20 + image10.getHeight(this)));boolean in_11 = (evt.x > 20 && evt.x < (20 +image11.getWidth(this)) && evt. y > 120 && evt.y < (120 + image11.getHeight(this)));boolean in_12 = (evt.x > 20 && evt.x < (20 +image12.getWidth(this)) && evt. y > 20 && evt.y < (20 + image12.getHeight(this)));switch(evt.id) {case Event.MOUSE_MOVE:if (in_12) {if (!r1) {r1 = true;which = 1;repaint();repaint_needed++;}}else {if (r1) {r1 = false;last_roll = 1;which = 1;repaint();repaint_needed++;}}break;}switch(evt.id) {case Event.MOUSE_MOVE:if (in_11) {if (!r2) {r2 = true;which = 2;repaint();repaint_needed++;}}else {if (r2) {r2 = false;last_roll = 2;which = 2;repaint();repaint_needed++;}}break;}switch(evt.id) {case Event.MOUSE_MOVE:if (in_10) {if (!r3) {r3 = true;which = 3;repaint();repaint_needed++;}}else {if (r3) {r3 = false;last_roll = 3;which = 3;repaint();repaint_needed++;}}break;}switch(evt.id) {case Event.MOUSE_MOVE:if (in_9) {if (!r4) {r4 = true;which = 4;repaint();repaint_needed++;}}else {if (r4) {r4 = false;last_roll = 4;which = 4;repaint();repaint_needed++;}}break;}switch(evt.id) {case Event.MOUSE_DOWN:c1 = in_12;if (in_12) {if (c1) t1 = !t1;which = 5;repaint();repaint_needed++;}break;case Event.MOUSE_UP:c1 = false;if (in_12) {}break;default:if (c1 && !in_12) {c1 = false;}}switch(evt.id) {case Event.MOUSE_UP:if (in_11) {if (t2 && url13 != null) getAppletContext().showDocument(url13);}break;case Event.MOUSE_DOWN:t2 = in_11;}switch(evt.id) {case Event.MOUSE_DOWN:t3 = in_10;if (in_10) {if (t3 && sound14 != null) sound14.play();}break;case Event.MOUSE_UP:t3 = false;if (in_10) {if (sound14 != null) sound14.stop();}break;default:if (t3 && !in_10) {if (sound14 != null) sound14.stop();t3 = false;}}switch(evt.id) {case Event.MOUSE_UP:if (in_9) {if (c4) t4 = !t4;which = 6;repaint();repaint_needed++;}break;case Event.MOUSE_DOWN:c4 = in_9;}for (int i=0; i