日期:2014-05-20 浏览次数:20815 次
import java.awt.Color; import java.awt.EventQueue; import java.awt.Frame; import java.awt.Graphics; public class TestPaint { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new PaintFrame().launchFrame(); } }); } } class PaintFrame extends Frame { public void launchFrame() { setBounds(200, 200, 640, 640); setVisible(true); } @Override public void paint(Graphics g) { Color c = g.getColor(); g.setColor(Color.red); g.drawOval(50, 50, 30, 30); g.setColor(Color.green); g.drawRect(50, 50, 50, 50); g.setColor(c); } }