Solved

different actionPerformed() for a button

Posted on 2004-04-12
3
359 Views
Last Modified: 2006-11-17
Hi there, I'm fairly new to java and i need some help. I have a TextFiled and a Button and i want eh buton to do a different actionPerformed than the TextField. How would I go about doing that? Here was my random try but it didnt work! :(

//Buttons
clear = new Button("Clear");
clear.addActionListener( new ComponentAdapter() {
      public void actionPerformed (ActionEvent ae) {
            //TextArea Clear
            recv.setText("");
      }
});
add(clear, "East");

thanks in advance,
gf3
gf3@bm3.org
0
Comment
Question by:gf3
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 85 total points
ID: 10808153
Should be:

clear.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
            recv.setText("");
      }
});
0
 
LVL 1

Author Comment

by:gf3
ID: 10808225
thanks so much!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10808240
8-)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 58
nestparen challenge 4 57
@SBGen Method 3 25
Java passing arguments (type error) 2 35
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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

746 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

13 Experts available now in Live!

Get 1:1 Help Now