import java.awt.*;
import java.awt.event.*;
public class smp61 extends Frame implements ActionListener{
Button btn = new Button("退出");
public smp61(){
btn.setBackground(Color.yellow);
btn.setForeground(Color.blue);
add(btn);
setVisible(true);
pack();
btn.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==btn){
System.exit(0);
}
}
public static void main(String args[]){
smp61 smp = new smp61();
}
}
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class smp61 extends Frame implements ActionListener
{
Button btn=new Button("退出");
smp61()
{
btn.setBackground(Color.yellow);
btn.setForeground(Color.blue);
add(btn);
setVisible(true);
pack();
btn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
{
System.exit(0);
}
}
public static void main(String args[])
{
smp61 smp=new smp61();
}
}
actionPerformed(),p大写,构造方法没有返回值