Java Applet: addTextListener method undefined???


 
Thread Tools Search this Thread
Top Forums Programming Java Applet: addTextListener method undefined???
# 1  
Old 04-30-2012
Java Applet: addTextListener method undefined???

Hi friends,
I hope everyone is doing fine and well. I am wrtting a small applet in java which listens to changes in text fields. Please have a look at my code, then we will talk about it.

Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.TextEvent;
import javax.swing.*;
import java.awt.event.TextListener;
import java.awt.TextComponent;
 
 
public class Event_Handling extends Applet implements TextListener
{
String s;
 
public void init()
{
addTextListener( this ); // Compiler says it(addTextListener) is not defined
addTextListener( this );
TextField tf1 = new TextField();
add( tf1 );
}
public void paint( Graphics g )
{
g.drawString(msg, 50, 50);
}
public void textValueChanged( TextEvent te )
{
msg = "Text value changed";
repaint();
}
}

Java compiler doesn't recognize addTextListener, what must be the problem. It does recognize addMouseListener, but why not addTextListener???

Looking forward to your replies.
Thanks

Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 04-30-2012 at 12:51 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Perl error: Can't call method "value" on an undefined value

Hi, I am running a perl script to automate a process and I keep running into a error can't find the "value" Can't call method "value" on an undefined value at process_file.pl line 44. file is CVS cell is ifdfdxrfmp.ksh Here is the script I have also attached it as well: ... (2 Replies)
Discussion started by: vpundit
2 Replies

2. Programming

modifying 2 or more values using method in Java

i wanna make modification in two or more identifiers,using a method in JAVA , but the only way to do this is by returning a value ,then also only one variable value can be modified .. one way 2 do do this is by use of array and passing its name in method ,, please suggest a different way of doing... (2 Replies)
Discussion started by: upvan111
2 Replies

3. Solaris

svc:/network/physical:default: Method "/lib/svc/method/net-physical" failed with exit status 96. [ n

After a memory upgrade all network interfaces are misconfigued. How do i resolve this issue. Below are some out puts.thanks. ifconfig: plumb: SIOCLIFADDIF: eg000g0:2: no such interface # ifconfig eg1000g0:2 plumb ifconfig: plumb: SIOCLIFADDIF: eg1000g0:2: no such interface # ifconfig... (2 Replies)
Discussion started by: andersonedouard
2 Replies

4. Shell Programming and Scripting

Calling Java Method from UNIX using shell script

Hi All, I need to call a java method from a shell script. I know we can use the command java ClassName to call the main method in it. But I need to call another method that is there in the class and pass an email to it. Can I use java ClassName.MethodName(email) Any help will be... (4 Replies)
Discussion started by: RahulK
4 Replies

5. Programming

Not able to execute the method based on OS in JAVA

Hi, In my application,I want to find out the OS name and based on OS I want to do some specific operations.So I write some code based on it in JAVA but I am able to get the OS name but Not able to use the method specific to OS.I write a simple code to check it and found that it is not going to... (1 Reply)
Discussion started by: smartgupta
1 Replies

6. UNIX for Dummies Questions & Answers

Linux task applet

Hi there, My task applet in Linux has crashed and I can't find how to activate it again!!! I am running Redhat Linux 7.1, and I am using the Gnome GUI. Would anyone have any ideas? Ta (2 Replies)
Discussion started by: ghoti
2 Replies
Login or Register to Ask a Question