请问为什么画不了图形,反而出现一些黑框

代码如下
package cn.sxt.game;

import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
/**

  • 飞机游戏窗口
  • @author 刘 * */

public class MyGameFrame extends JFrame{
public void paint(Graphics g) {
//g.drawLine(50,50,100,100);
g.drawRect(100,100,300,300);

}

//初始化窗口
public void launchFrame() {
    this.setTitle("L");         //窗口标题
    this.setVisible(true);          //窗口可视
    this.setSize(500,500);          //窗口大小
    this.setLocation(300,300);      //窗口位置

    this.addWindowListener(new WindowAdapter(){
        @Override
            public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

public static void main(String[] args) {
    MyGameFrame f = new MyGameFrame();
    f.launchFrame();
}

}