What is wrong with this.
Hi, i have been programming with java for 2 days and now i am stuck can some one please help me?
It says that i can not use actionlistener with the button, but why?
Thanks in advance
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass whyimplements ActionListener{
publicstaticvoid main (String[] args){
why gui =new why();
gui.go();
}
publicvoid go(){
Container contentPane;
JFrame frame =new JFrame();
JPanel panel =new JPanel();
panel.setBackground(Color.darkGray);
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JButton button =new JButton("click me");
JButton button2 =new JButton("do not click me");
JTextField field =new JTextField("Tedstt");
button2.addActionListener(field);
panel.add(button);
panel.add(button2);
contentPane.add(field);
frame.getContentPane().add(BorderLayout.EAST, panel);
frame.setSize(400,400);
frame.setVisible(true);
}
publicvoid actionPerformed(ActionEvent event){
JButton button;
button.setText("yrdy");
}
}

