import java.awt.*;
import javax.swing.*;
class MyJFrame
{
public static void main(String[] args)
{
JFrame fr = new JFrame();
fr.setTitle("这是一个JFrame,它不同于AWT的Frame");
FlowLayout fl = new FlowLayout();
fr.getContentPane().setLayout(fl);//必须先用getContentPane()方法返回内容面板,这不同于AWT的Frame
fr.setSize(300,400);
fr.getContentPane().setBackground(Color.green);
fr.setLocation(200,500);
fr.setResizable(true);
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设定窗口可以关闭,而在AWT中还需要注册监听
fr.setVisible(true);
}
}