Link to home
Start Free TrialLog in
Avatar of Yoda
Yoda

asked on

Drawing a background image on an applet

I have an applet that just has a few textfields and two buttons on it.  The html page that this applet runs on has
a background image called altgry02.jpg.  How can I draw this background image on the applet also so that the applet appears to blend in with the html page.  This is the code for my applet:

/*
    A basic extension of the java.applet.Applet class
 */

import java.awt.*;
import java.applet.*;

public class TestApplet extends Applet {

      public void init() {
            super.init();

            // Take out this line if you don't use symantec.itools.net.RelativeURL
        //symantec.itools.lang.Context.setDocumentBase(getDocumentBase());

            //{{INIT_CONTROLS
            setLayout(null);
            addNotify();
            resize(350,229);
            textField1 = new java.awt.TextField();
            textField1.reshape(96,61,150,28);
            add(textField1);
            textField2 = new java.awt.TextField();
            textField2.reshape(97,101,150,28);
            add(textField2);
            button1 = new java.awt.Button("button");
            button1.reshape(96,146,60,23);
            add(button1);
            button2 = new java.awt.Button("button");
            button2.reshape(177,146,59,23);
            add(button2);
            label1 = new java.awt.Label("This is my applet");
            label1.reshape(41,21,262,25);
            add(label1);
            //}}
      }

      public boolean handleEvent(Event event) {
            return super.handleEvent(event);
      }

      //{{DECLARE_CONTROLS
      java.awt.TextField textField1;
      java.awt.TextField textField2;
      java.awt.Button button1;
      java.awt.Button button2;
      java.awt.Label label1;
      //}}
}

What do I need to add to get the background image altgry02.jpg to be drawn on this applet and then have
the components on the applet drawn over this image?
Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Ted Hopp
Ted Hopp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial