Forums Register Login

Instantiation Error in AWT Applet code

+Pie Number of slices to send: Send
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");
addMouseListener(this);

}
public void paint(Graphics g) {

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

}
We begin by testing your absorbancy by exposing you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 817 times.
Similar Threads
Gray box where my applet should be
Circle collision Detection: Solved =)
Fluid Motion Moving Circles Smooth -solved-
placing images in applets
AWT Applet Instantiation Error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:37:34.