aspose file tools*
The moose likes Applets and the fly likes Instantiation Error in AWT Applet code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Instantiation Error in AWT Applet code" Watch "Instantiation Error in AWT Applet code" New topic
Author

Instantiation Error in AWT Applet code

David Record
Greenhorn

Joined: Jun 14, 2001
Posts: 7
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();
}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instantiation Error in AWT Applet code