import java.awt.Color; import java.awt.Color; import java.awt.Frame; import java.awt.event.WindowEvent; import java.awt.event.WindowAdapter; public class MyJava extends Frame{ public MyJava(String FormName){ super(FormName); } public static void main(String [] args){ MyJava FirstFrame=new MyJava("This is my first Frame"); FirstFrame.setSize(200,140); //FirstFrame.setBackgroud(Color.BLUE); //一直未成功,这是为什么呢?网上也没找到原因。 FirstFrame.setVisible(true); FirstFrame.addWindowListener(new MyWindowAdapter ()); } } class MyWindowAdapter extends WindowAdapter { public void windowClosing(WindowEvent we) { System.exit(0); } }