1.new一个对象出来 如: Frame fm=new Frame() ,Panel pn=new Panel();
2. 设置背景色 fm.setBackground(Color.pink);
3. 设置大小和位置 fm.setBounds(45,45,400,300);//注: fm.setLocation(45,45);加fm.setSize(400,300)也能达到同样效果
4. 设置布局 fm.setLayout(null);//取消默认布局.
5.setResizable(true);//是否可以鼠标拖拉窗口尺寸
6.讲组件添加到Frame中 fm.add(pn);
7.设置可见 fm.setVisible(true);