Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Applet, TextField, addActionListener

Posted on 1998-02-24
3
Medium Priority
?
1,394 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 300 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…
Suggested Courses

718 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