抽象类不能实例化,但是请看下面这个程序,为什么可以new WindowAdapter()?class FrameTest4 { public static void main(String[] args){ new NewFrame("窗口"); }}class NewFrame extends Frame{ TextArea text; NewFrame(String s){ super(s); setBounds(100,100,200,300); setVisible(true); text=new TextArea();add(text,BorderLayout.CENTER); addWindowListener(new WindowAdapter(){ public void windowActivated(WindowEvent e){ text.append("\n我被激活"); } public void windowClosing(WindowEvent e){ System.exit(0); } }); validate(); } }
添加回答
举报
0/150
提交
取消