画笔
package com.yuecheng.guistudy;
import java.awt.*;
public class TestPaint01 {
public static void main(String[] args) {
new myPaint().loadFrame();
}
}
class myPaint extends Frame{
public void loadFrame(){
setBounds(200,200,500,500);
setVisible(true);
}
//创建画笔
@Override
public void paint(Graphics g) {
//super.paint(g);
//画笔需要有颜色,画笔可以画画
g.setColor(Color.blue);
g.drawOval(100,100,100,100);
g.fillOval(200,300,100,100);
g.setColor(Color.yellow);
g.fillRect(50,50,50,50);
//养成习惯,用完还原最初颜色
g.setColor(Color.BLACK);
}
}