Friday, March 9, 2012

Whats WRONG?!

Hi!
I have been working on this question for a few days now. I don`t know whats wrong in my code! I have scanned the internet and on every site, the code is the same, as in what I have made! I need help! You can tell me in the comments, or you can go to Yahoo Answers, and answer it there! Thanks for your help! And here is the code:

/*
* Made by pepluser.
* pepluser.blogspot.com
*/
package test2;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;



/**
*
* @author Peter
*/
public class Test2 implements ActionListener {

/**
* @param args the command line arguments
*/


public static void main(String[] args) {
ActionListener a = null;

JFrame f1;
JButton button;

f1 = new JFrame("Test2");


button = new JButton("Hello");
button.addActionListener(a);

f1.add(button);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.setVisible(true);


}



public void actionPerformed(ActionEvent a) {
button.setText("Goodbye");


}


}





I made this in NetBeanes, a free java IDE! Thanks for your help!