需要继承JFrame类
public class GameFrame extends JFrame{}
setTitle();//设置窗口的标题
setSize(int x ,int y)//设置窗口的大小
setLocationRelativeTo(null) //居中显示窗口
setLcation(int x,int y);//设置指定位置 x为横坐标 ,y为纵坐标
setResizable(false);//设置设置禁止改变界面的大小
定义后调用paint
public void paint(Graphics g) {
super.paint(g);//这行代码必须有`在这里插入代码片
g.setColor(Color.red);//设置画笔颜色
//也可以这样
//创建颜色 new color(红色数值,绿色数值,蓝色数值)
g.setColor( new Color(105,139,105))
//new Font("字体名称",字体样式,字体大小)
g.setFont(new Font("楷体",Font.BOLD,30))
//画文字
g.drawString("文字内容",横坐标,纵坐标);
//画图形
//画空心矩形
//g.drawRect(横坐标, 纵坐标, 宽, 高);
g.drawRect(50, 50, 100, 100);
//画实心矩形
//g.fillRect(横,纵, 宽, 高);
g.fillRect(200, 50, 100, 100);
//画空心圆
//g.fillOval(x, y, width, height);
//画直线 起点坐标 终点坐标
//g.drawLine(x1, y1 , x2, y2);