Solved

java function not found

Posted on 1998-08-24
2
171 Views
Last Modified: 2013-11-23
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);
         }

}


0
Comment
Question by:stephan papadakis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:stephan papadakis
ID: 1222459
Edited text of question
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
ID: 1222460
Most likely you are running your applet in non-JDK 1.1 compatible version of Navigator. To make sure that your applet is correct, try running in appletviewer. If it works fine and you indeed were using Netscape, get a latest version of communicator or download a JDK 1.1 patch for your version. You can find then in Java are on http://developer.netscape.com.

Let me know if you need more information.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question