画笔

package com.hua.demo3;

import java.awt.*;

public class TextPaint {
    public static void main(String[] args) {
        MyPaint myPaint = new MyPaint();
    }
}
class MyPaint extends Frame {
    public MyPaint() {
        setVisible(true);
        setBounds(200, 200, 600, 500);
    }

    //画笔
    @Override
    public void paint(Graphics g) {
        //画笔,需要有颜色,画笔可以画图
        g.setColor(Color.red);
//        g.drawOval(100,100,100,100);
        g.fillOval(100, 100, 100, 100);//实心的圆

        g.setColor(Color.green);
        g.fillRect(100, 200, 100, 150);

        //养成习惯,画笔用完,将他还原到最初的颜色
    }
}

 

posted @ 2022-01-19 23:39  少时凌云志  阅读(48)  评论(0)    收藏  举报