stephan papadakis
asked on
java function not found
I wrote this litte program. I compiled it and every time i try to run this applet i get the following
message:
Info :java.lang.NoSuchMethodErr or: java.awt.Component: method enableEvents(J)V not found
Can you please tell me why?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
class Blatt
extends Canvas
{
private boolean clicked;
private Point Position;
public Blatt()
{ this.Position.x = 20;
this.Position.y = 20;
this.clicked = false;
enableEvents(AWTEvent.MOUS E_EVENT_MA SK);
}
public Blatt(Point Punkt)
{
this.Position = Punkt;
this.clicked = false;
enableEvents(AWTEvent.MOUS E_EVENT_MA SK);
}
public void paint(Graphics g)
{
if(!this.clicked)
g.drawRect(this.Position.x ,this.Posi tion.y,20, 20);
else
{
g.fillRect(this.Position.x ,this.Posi tion.y,20, 20);
}
}
protected void processMouseEvent(MouseEve nt event)
{
if (event.getID() == MouseEvent.MOUSE_PRESSED)
{
if (clicked) clicked = false ;
else
clicked = true;
}
repaint();
super.processMouseEvent(ev ent);
}
}
public class BrainApplet extends Applet
{
public void init()
{
Blatt b = new Blatt();
add(b);
validate();
}
public void paint(Graphics g)
{
g.drawString("Welcome to this tutorial! Value ", 20, 20);
}
}
message:
Info :java.lang.NoSuchMethodErr
Can you please tell me why?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
class Blatt
extends Canvas
{
private boolean clicked;
private Point Position;
public Blatt()
{ this.Position.x = 20;
this.Position.y = 20;
this.clicked = false;
enableEvents(AWTEvent.MOUS
}
public Blatt(Point Punkt)
{
this.Position = Punkt;
this.clicked = false;
enableEvents(AWTEvent.MOUS
}
public void paint(Graphics g)
{
if(!this.clicked)
g.drawRect(this.Position.x
else
{
g.fillRect(this.Position.x
}
}
protected void processMouseEvent(MouseEve
{
if (event.getID() == MouseEvent.MOUSE_PRESSED)
{
if (clicked) clicked = false ;
else
clicked = true;
}
repaint();
super.processMouseEvent(ev
}
}
public class BrainApplet extends Applet
{
public void init()
{
Blatt b = new Blatt();
add(b);
validate();
}
public void paint(Graphics g)
{
g.drawString("Welcome to this tutorial! Value ", 20, 20);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER