• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

different actionPerformed() for a button

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
gf3
Asked:
gf3
  • 2
1 Solution
 
CEHJCommented:
Should be:

clear.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
            recv.setText("");
      }
});
0
 
gf3Author Commented:
thanks so much!
0
 
CEHJCommented:
8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now