抽象類不能實例化,但是請看下面這個程序,為什么可以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
提交
取消