資源簡介
Java Applet中的圖形加運算(提高篇-實例576).zip
代碼片段和文件信息
package?com.zzk;
import?java.applet.applet;
import?java.awt.Graphics;
import?java.awt.Graphics2D;
import?java.awt.geom.Area;
import?java.awt.geom.Rectangle2D;
public?class?AddOperationapplet?extends?applet?{
????public?void?paint(Graphics?g)?{
????????String?value?=?“圖形相加運算“;
????????Graphics2D?g2d?=?(Graphics2D)?g;//?p轉換為可用的Graphics2D對象
????????Rectangle2D.Float?rect1?=?new?Rectangle2D.Float(20?70?185?60);//?創建矩形對象
????????Rectangle2D.Float?rect2?=?new?Rectangle2D.Float(120?20?65?160);//?創建矩形對象
????????Area?area1?=?new?Area(rect1);//?創建區域矩形
????????Area?area2?=?new?Area(rect2);//?創建區域矩形
????????area1.add(area2);//?兩個區域進行相加
????????g2d.draw(area1);//?繪制相加后的區域矩形
????????Rectangle2D.Float?rect3?=?new?Rectangle2D.Float(230?70?185?60);//?創建矩形對象
????????Rectangle2D.Float?rect4?=?new?Rectangle2D.Float(290?20?65?160);//?創建矩形對象
????????Area?area3?=?new?Area(rect3);//?創建區域矩形
????????Area?area4?=?new?Area(rect4);//?創建區域矩形
????????area3.add(area4);//?兩個區域進行相加
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????301??2010-12-22?08:52??.classpath
?????文件?????????379??2010-12-22?08:52??.project
?????文件?????????629??2010-12-22?08:52??.settings\org.eclipse.jdt.core.prefs
?????文件?????????109??2010-12-22?08:52??bin\AddOperationap
?????文件?????????141??2010-12-28?11:07??bin\java.policy.ap
?????文件????????1305??2011-01-29?09:04??bin\com\zzk\AddOperationap
?????文件?????????109??2010-12-22?08:52??src\AddOperationap
?????文件????????1198??2010-12-28?11:08??src\com\zzk\AddOperationap
- 上一篇:Java ap
plet繪制多角形 - 下一篇:Java 繪制文本
評論
共有 條評論