• Post Reply Bookmark Topic Watch Topic
  • New Topic

Instantiation Error in AWT Applet code  RSS feed

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me. I keep getting an instantiation error in my code. it compiles fine, but doesn't work. I'm trying to place an image wherever I click the mouse in the applet.
here's the code
//<applet code="AppletApp.class" width=200 height=300></applet>
import java.awt.*; //<-- added code
import java.applet.*; //<-- added code
import java.awt.event.*; //<-- added code
abstract class AppletApp extends Applet implements MouseListener{

private Image duke;
private int xPos,yPos;

public void init() {

duke = getImage(getDocumentBase(),"duke.gif");

public void paint(Graphics g) {

g.drawImage(duke, xPos, yPos, this);
public void mousePressed(MouseEvent e) {
xPos = e.getX();
yPos = e.getY();

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!