24 Graphics类 import java. awt. *r public class My Frame extends Framef My Frame(t super(" Java U窗口") setsize(200, 200); public void paint(Graphics g)t gsetcolor(Color. RED); g drawLine(10,20,140,140) g drawString("中华人民共和国",100,100) public static void main(String args[]i new My Frame( setVisible(true) Por gr amming in Java 2008.3-2008 7 by Yan jun Zhang, Depar tment of Computer HanDan Col lage绪 论 Porgramming in Java 2008.3-2008.7 by Yanjun Zhang,Department of Computer HanDan Collage. 2.4 Graphics类 import java.awt.*; public class MyFrame extends Frame{ MyFrame(){ super("Java GUI窗口"); setSize(200,200); } public void paint(Graphics g){ g.setColor(Color.RED); g.drawLine(10,20,140,140); g.drawString("中华人民共和国",100,100); } public static void main(String args[]){ new MyFrame().setVisible(true);; } }