please tell me the error about java Graphics

时间:2021-10-23 13:33:13

this is the code:

public class paint extends JFrame{
public paint(){
setLayout(new FlowLayout());
setLocation(0, 0);
setSize(200, 200);

setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Container con=getContentPane();
con.add(new draw());

}

public static void main(String args[]){

new paint().setVisible(true);

}

class draw extends JPanel{

@Override
public void paint(Graphics g) {
// TODO 自动生成的方法存根
//super.paint(g);

g.drawRect(10, 10, 60, 60);
g.drawLine(70, 80, 180, 50);
System.out.print("fuck you");

}

}
}