【www.gdgbn.com--显示器】


   学习笔记之JAVA图形设计卷I AWT――第3章 图 形

前时显示器坏了,file://写前言:我觉得写的不是学习笔记,倒象教程。我是想让有所获,故详细了点。
注意1:在AWT中提供的用户接口构件(如按钮、列表、菜单、对话框等)不包含一些类似的纯粹的绘制图形的对象(如Line或Circle类)

详细意思:由于原始的AWT在设计时不允许纯粹的绘制图形的对象,那么Rectangle、Polygon和Point没有任何绘制图形的能力。换句话说,
Rectangle、Polygon和Point不具备draw方法。您可做的,仅仅是可以设置和得到它们代表的几何实体的信息。
为了代替那些纯粹的、可绘制图形的对象,AWT使用了一种简单的――尽管不够灵活并且不易扩展――模式:
每个AWT构件完全来自于它自己的JAVA.AWT.Graphics对象,尽管其中的一些图形操作可以在与之相关的构件中实现。
Graphics也可以向种各样的输出设备中绘制,像画面外缓冲器和打印机――参见第24章“双缓冲技术”和18.4节“打印”中的相关内容。

请先看两张表(都忽略了JAVA.AWT.peer方法):

        表3-1 传递一个对Graphics的引用的JDK方法
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   软件包     类         方 法
  ─────────────────────────────────
  JAVA.AWT   Canvas       paint(Graphics g)
         Component     paint(Graphics g)
         Component     paintAll(Graphics g)
         Component     print(Graphics g)
         Component     printAll(Graphics g)
         Component     update(Graphics g)
         Container     paint(Graphics g)
         Container     paintComponents(Graphics g)
         Container     print(Graphics g)
         Container     printComponents(Graphics g)
         ScrollPane     printComponents(Graphics g)
  

本文来源:http://www.gdgbn.com/bangongshuma/13252/