Solved

java function not found

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

Technology Partners: 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

617 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