58,453
社区成员




import java.awt.*;
import java.awt.event.*;
public class fram extends Frame implements ActionListener {
static Button btn;
fram(){
super("Frame with Button");
setVisible(true);
btn=new Button("退出");
setBackground(Color.yellow);
setForeground(Color.blue);
//setResizable(false);//不可更改大小
//setSize(380,500);//设置大小
add(btn);
pack();
btn.addActionListener(this);
}
static void addPerformed(ActionEvent e){
if (e.getSource()==btn) {
System.exit(0);
}
}
public static void main(String[] args) {
fram frm =new fram();// TODO Auto-generated method stub
}
}
frame1.java:3: frame1 不是抽象的,并且未覆盖 java.awt.event.ActionListener 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)import java.awt.*;
import java.awt.event.*;
public class pel extends Frame implements ActionListener {
static Button btn;
pel() {
super("Panel with button");
Panel p1 = new Panel();
add(p1);
btn=new Button("exit");
p1.add(btn);
pack();
btn.addActionListener(this);
}
static void addPerformed(ActionEvent e) {
if (e.getSource()=btn) {
System.exit(0);
}
}
public static void main(String[] args) {
pel p = new pel();
}
}
F:\000\work\111>javac pel.javaActionListener.actionPerformed(ActionEvent)