有个错误.21行.但是我不知道怎么改.
我看不出来哪错了...
各位大哥帮帮忙
import java.awt.*;
import java.awt.event.*;
public class Ziti
{
public static void main(String[] args)
{
Frame f=new Frame("字体改变大小");
f.setSize(400,400);
f.setLocation(100,100);
f.setBackground(Color.red);
f.setLayout(new FlowLayout());
Button b1=new Button("确定");
Button b2=new Button("取消");
f.add(b1,"West");
f.add(b2,"East");
f.addWindowListener(new Shijian());
f.show();
}
}
class Shijian implements WindowListener
{
public void windowOpened(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowClosed(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
}
----------------解决方案--------------------------------------------------------
WindowListener 接口中的方法你没有覆盖完
----------------解决方案--------------------------------------------------------
晕死哦.
谢谢楼上的哈.
视频教程.
估计少了几个
----------------解决方案--------------------------------------------------------
有个错误.21行.但是我不知道怎么改.
我看不出来哪错了...
各位大哥帮帮忙
import java.awt.*;
import java.awt.event.*;
public class Ziti
{
public static void main(String[] args)
{
Frame f=new Frame("字体改变大小");
f.setSize(400,400);
f.setLocation(100,100);
f.setBackground(Color.red);
f.setLayout(new FlowLayout());
Button b1=new Button("确定");
Button b2=new Button("取消");
f.add(b1,"West");
f.add(b2,"East");
f.addWindowListener(new Shijian());
f.show();
}
}
/*class Shijian implements WindowListener
{
public void windowOpened(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowClosed(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
}*/
注释掉的部分下面这样写就行了 不用把发放都写出来很烦的 用什么写什么比较好吧
class Shijian extends WindowAdapter{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
或者
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
----------------解决方案--------------------------------------------------------
楼上说的对,用适配器就行了
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
呵呵。晕乎乎。
不过还是谢谢各位
----------------解决方案--------------------------------------------------------