Solved

Applet, TextField, addActionListener

Posted on 1998-02-24
3
1,391 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
[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
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

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…
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 about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

752 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