Hi thanks for the reply, i have looked around messages for what you said to do, and have found some examples, but i have produced rubbish.
Java is new to me and i am strugling. This is a coursework project, and i have produced a working version but it uses swing which they warned us against so i'm now trying with just AWT components. I added a bit in about extending the panel but really don't know what i'm doing. I've cut my code back to the basics so if someone could just show how to paint the gif on panel1 that would be a huge help. Thnks
package coursework;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.Image;
public class JamJars
extends Applet {
private boolean isStandalone = false;
Image myImage;
BorderLayout borderLayout1 = new BorderLayout();
Panel lower = new Panel();
Panel upper = new Panel();
CardLayout cardLayout1 = new CardLayout();
Panel game = new Panel();
GridLayout gridLayout1 = new GridLayout();
Panel panel1 = new Panel();
class paintPanel
extends Panel {
public void paintPanel() {
}
public void paint(Graphics g) {
g.drawImage(1, 1, myImage, panel1);
}
}
//Get a parameter value
public
String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public JamJars() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
myImage = getImage(getCodeBase(), "jar.gif");
//myGrap = getGraphics(myImage);
this.setVisible(true);
this.setLayout(borderLayout1);
MediaTracker mt = new MediaTracker(this);
mt.addImage(myImage, 0);
try {
mt.waitForAll(); // blocks here until Image is fully downloaded
}
catch (InterruptedException e) {
}
lower.setLayout(cardLayout1);
game.setLayout(gridLayout1);
game.setBackground(Color.white);
panel1.setBackground(Color.white);
this.add(lower, BorderLayout.CENTER);
this.add(upper, BorderLayout.NORTH);
lower.add(game, "game");
game.add(panel1, null);
}
//Start the applet
public void start() {
}
//Stop the applet
public void stop() {
}
//Destroy the applet
public void destroy() {
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}