Solved

java function not found

Posted on 1998-08-24
2
156 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
2 Comments
 

Author Comment

by:stephan papadakis
Comment Utility
Edited text of question
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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 …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now