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");
}
}
}
时间: 2024-11-07 23:06:07