Link to home
Start Free TrialLog in
Avatar of stephan papadakis
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.NoSuchMethodError: 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.MOUSE_EVENT_MASK);
   }

   public Blatt(Point Punkt)
   {
      this.Position = Punkt;
      this.clicked = false;
      enableEvents(AWTEvent.MOUSE_EVENT_MASK);
   }

   public void paint(Graphics g)
   {
     if(!this.clicked)
      g.drawRect(this.Position.x,this.Position.y,20,20);
     else
     {
       g.fillRect(this.Position.x,this.Position.y,20,20);
     }
   }

     protected void processMouseEvent(MouseEvent event)
   {

      if (event.getID() == MouseEvent.MOUSE_PRESSED)
        {
         if (clicked) clicked = false ;
           else
            clicked = true;

        }
         repaint();

      super.processMouseEvent(event);
   }
}


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);
         }

}


Avatar of stephan papadakis
stephan papadakis

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of msmolyak
msmolyak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial