//Graphics类---简单的画图实现 import java.awt.*; public class TestPaint { public static void main(String[] args) { new PaintFrame().launchFrame(); } } class PaintFrame extends Frame { public void launchFrame() { setBounds(200, 200, 700, 500); setVisible(true); } public void paint(Graphics g) {//每次需要重画时自动调用paint()方法 Color c = g.getColor(); g.setColor(Color.red); g.fillOval(50, 50, 50, 50); g.setColor(Color.green); g.fillRect(100, 100, 80, 80); g.setColor(c); } }