急!请教高手!!!
import MyWindowListener;app.addWindowListener(new MyWindowListener());
以上2行提示错误。
代码附上(eclipse环境下:):
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import MyWindowListener;
public class MyFrame extends JFrame{
Container c;
String closeOperationName[]=
{
"WindowConstants.DO_NOTHING_ON_CLOSE",
"WindowConstants.HIDE_ON_CLOSE",
"WindowConstants.DISPOSE_ON_CLOSE"
};
public MyFrame()
{
super("MyFrame.java:JFrame测试");
c=getContentPane();
setSize(450,140);
show();
}
public void paint(Graphics g)
{
g.setFont(new Font("Serif",Font.BOLD,14));
g.drawString("JFrame:"+paramString(),10 ,50);
g.drawString("Container:"+c.toString(), 10, 80);
g.drawString("close Operation:"+closeOperationName[getDefaultCloseOperation()], 10, 110);
}
public static void main(String args[])
{
MyFrame app=new MyFrame();
app.addWindowListener(new MyWindowListener());
}
}