Solved

different actionPerformed() for a button

Posted on 2004-04-12
3
367 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
[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
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:
Suggested Courses

738 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