Solved

Applet, TextField, addActionListener

Posted on 1998-02-24
3
1,382 Views
Last Modified: 2013-11-23
I have trouble with a TextField within an applet. I just want a simple TextField and add an ActionListener but
ist doesn´t work right.
Here is the code:

import java.awt.event.*;
import java.applet.*;
import java.lang.*;
import java.awt.*;

public class testapp extends Applet implements ActionListener {

    TextField tf;

    public void init() {
        setLayout(null);
        tf = new TextField("Meier",20);
        tf.addActionListener(this);
        add(tf);
    }
   
    public void actionPerformed (ActionEvent e) {
        Object obj = e.getSource();
        if ( obj instanceof TextField )
           System.out.println ("Field " + e.getActionCommand() );
    }    

    public void start(){
        System.out.println("Applet: start()...");
    }

    public void stop(){
       System.out.println("Applet: stop()...");
    }

    public void destroy() {
       System.out.println("Applet: destroy()...");

    }      
}

I can compile the programm without any errors and warings but when displaying I get this error mesage:

# Applet exception: error: java.lang.NoSuchMethodError: java.awt.TextField: method addActionListener (Ljava/awt/event/ActionListener;)V not found
java.lang.NoSuchMethodError: java.awt.TextField: method addActionListener (Ljava/awt/event/ActionListener;)V not found

Where is the problem ?

Guido
0
Comment
Question by:experte
3 Comments
 

Expert Comment

by:kls1
ID: 1233237
What are you using to display it?  Appletviewer...or a browser like Netscape? If Netscape, make sure you have the jdk 1.1 patches.
0
 

Author Comment

by:experte
ID: 1233238
Hi !
Yes, I forgot to tell you, I use the Netscape Communicator and I use
JDK 1.1.3
Guido
0
 
LVL 1

Accepted Solution

by:
datadesign earned 100 total points
ID: 1233239
But do u have the jdk 1.1 patch for the Communicator ?
If not, install the patch, and the Applet should work without any problems ! (Applet running in your browser, dont access the jdk 1.1.3 u have installed, they use their own VM.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

863 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

20 Experts available now in Live!

Get 1:1 Help Now