请问我这个程序有哪儿错了啊?
我真的找不出来import java.awt.*;
import java.awt.event.*;
public class J implements ActionListener{
public static void main(String[] a){Frame f=new Frame("agoiajp");setSize(500,500);
setVisibel(true);
Panel p=new Panel();
Button b=new Button("hao");
p.add(b);
f.add(p);
b.addActionListener(this);
toolkit=getToolkit();public void actionPerformed(ActionEvent e)
{if(e.getsource()==b)
{toolkit.beep();
b.setBackground(Color.green);}}
}
}
我真的找不出来import java.awt.*;
import java.awt.event.*;
public class J implements ActionListener{
public static void main(String[] a){Frame f=new Frame("agoiajp");setSize(500,500);
setVisibel(true);
Panel p=new Panel();
Button b=new Button("hao");
p.add(b);
f.add(p);
b.addActionListener(this);
toolkit=getToolkit();public void actionPerformed(ActionEvent e)
{if(e.getsource()==b)
{toolkit.beep();
b.setBackground(Color.green);}}
}
}
import java.awt.event.*;public class Test implements ActionListener {
Toolkit toolkit = null;
Button b = null;
public static void main(String[] a) {
Test test = new Test();
Frame f = new Frame("agoiajp");
Panel p = new Panel();
test.b = new Button("hao");
p.add(test.b);
f.add(p);
test.b.addActionListener(test);
test.toolkit = f.getToolkit();
f.setSize(500, 500);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b) {
toolkit.beep();
b.setBackground(Color.green);
}
}
}