Solved

java function not found

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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 …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

737 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