Solved

different actionPerformed() for a button

Posted on 2004-04-12
3
365 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web services creation SOAP vs REST 5 56
java jdbc batch example 8 40
eclipse apache tomcat admin console 52 121
swing controls 2 15
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

809 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