• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • 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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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