/* Trivial applet that displays a string - 4/96 PNL */ import java.awt.*; import java.awt.event.*; import java.applet.*; import java.net.*; import java.awt.image.*; public class TrivialApplet extends Applet { Image img1, img2; public void init () { setFont (new Font ("fixed", Font.BOLD, 14)); // setSize (500,500); setBackground (Color.red); // Dimension dim = getSize(); // Stdio.println (dim); System.out.println (getDocumentBase()); img1 = getImage (getDocumentBase(), "image"); System.out.println (img1); URL theURL; try { theURL = new URL ("file:///HD/Desktop%20Folder/classes/cop3991/hw4/mr/image"); img2 = getImage(theURL); } catch (MalformedURLException xcp) { System.out.println ("Ooops !!!!"); } Button bPlot = new Button ("Plot"); add (bPlot); bPlot.addActionListener ( new ActionListener () { public void actionPerformed (ActionEvent e) { System.out.println ("Button clicked"); // repaint (); } }); } public void paint( Graphics g ) { g.drawString( "Hello World! xxxx ", 30, 30 ); g.drawImage (img1, 30, 30, this); g.drawImage (img2, 50, 50, this); g.drawString( "Bye World! zzzz ", 70, 70 ); } }