新手提问.关于窗口操作.
import java.awt.*;import java.awt.event.*;
class MyFrame extends Frame implements WindowListener
{
TextArea text;
MyFrame(String s)
{
super(s);
setBounds(100,100,100,100);
setVisible(true);
text=new TextArea();
add(text,BorderLayout.CENTER);
addWindowListener(this);
validate();
}
public void windowActivated(WindowEvent e)
{
text.append("\n 我被激活");
validate();
}
public void windowDeactivated(WindowEvent w)
{
text.append("\n 我不是激活状态");
setBounds(0,0,400,400);
validate();
}
public void windowClosing(WindowEvent e)
{
text.append("\n 窗口正在关闭");
dispose();
}
public void windowClosed(WindowEvent e)
{
System.out.println ("窗口关闭");
System.exit(0);
}
public void windowIconified (WindowEvent e)
{
text.append("\n 我图表化了");
}
public void windowDeiconified (WindowEvent e)
{
text.append("\n 我取消图表化了");
setBounds(0,0,400,400);
validate();
}
}
class Example
{
public static void main(String[] args) {
new MyFrame("window");
}
}
我完全按书上键入这些东西,但却有错误
MyFrame is not abstract and does not override abstract method windowOpened(java.awt.event.WindowEvent) in java.awt.event.WindowListener
然后窗口操作是操作右上角的那几个小图标么?
class MyFrame extends Frame implements WindowListener