以下为画笔paint的最基础操作。
package com.zhang.lesson03; import java.awt.*; public class TestPaint { public static void main(String[] args) { new MyPaint().loadFrame(); } } class MyPaint extends Frame{ public void loadFrame (){ setBounds(200,200,600,500); setVisible(true); } //画笔 @Override public void paint(Graphics g) { //画笔,需要有颜色 g.setColor(Color.BLUE); g.drawOval(100,100,100,100); g.fillOval(200,100,100,100); g.setColor(Color.YELLOW); g.fillRect(300,100,100,100); //画笔用完将他还原 } }