日期:2014-05-20 浏览次数:20709 次
import java.awt.*;
public class TestPaint {
public static void main(String[] args) {
new MyFrame().launchFrame();
//new PaintFrame().launchFrame();
}
}
class MyFrame extends Frame{
public void launchFrame(){
setBounds(100,100,200,300);
setVisible(true);
}
public void paint(Graphics g){//Graphics相当于VC中的CDC.DC
Color c=g.getColor();//保存原来画笔颜色
g.setColor(Color.red);
g.drawRect(10, 10, 50, 60);
g.setColor(Color.blue);
g.drawRoundRect(20, 30, 50, 60, 50, 40);
g.setColor(c);//恢复现场
}
}