Java 为什么下面的程序会出错呢??
“Java_2不是抽象的,并且未覆盖java.awt.event.WindowListener中的抽象方法windowClosing(java.awt.event.Win...
“Java_2不是抽象的,并且未覆盖java.awt.event.WindowListener中的抽象方法windowClosing(java.awt.event.WindowListener)”?
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class Java_2 extends Frame implements WindowListener {
public static void main(String args[]) {
Java_2 fr = new Java_2();
//*********Found**********
fr.setSize(200, 100);
fr.setBackground(Color.green);
//*********Found**********
fr.addWindowListener(fr);
fr.setVisible(true);
}
//*********Found**********
public void windowClosing(ActionEvent e) {
System.exit(0);
}
public void windowClosed(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
} 展开
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class Java_2 extends Frame implements WindowListener {
public static void main(String args[]) {
Java_2 fr = new Java_2();
//*********Found**********
fr.setSize(200, 100);
fr.setBackground(Color.green);
//*********Found**********
fr.addWindowListener(fr);
fr.setVisible(true);
}
//*********Found**********
public void windowClosing(ActionEvent e) {
System.exit(0);
}
public void windowClosed(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
} 展开
3个回答
展开全部
你的java_2类没实现java.awt.event.WindowListener中的抽象方法windowClosing(java.awt.event.WindowListener)
你建个空方法他就不暴错了
你建个空方法他就不暴错了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你用什么工具写代码的,eclipse提示很清楚,你少实现一个方法
public void windowClosing(WindowEvent e) {
// TOM Auto-generated method stub
}
你有一个
public void windowClosing(ActionEvent e) {
System.exit(0);
}
方法,不过参数不对,所以不行
public void windowClosing(WindowEvent e) {
// TOM Auto-generated method stub
}
你有一个
public void windowClosing(ActionEvent e) {
System.exit(0);
}
方法,不过参数不对,所以不行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public void windowClosing(ActionEvent e) {
System.exit(0);
}
改为
public void windowClosing(WindowEvent e) {
System.exit(0);
}
System.exit(0);
}
改为
public void windowClosing(WindowEvent e) {
System.exit(0);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询