freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

北大計算機系java講義--第二章java小程序-文庫吧

2025-04-24 18:44 本頁面


【正文】 (“rem”)。 if (title==null) title=“”。 } public void paint(Graphics g) { (msgFont)。 ()。 (title+ (),5,50)。 } 17 小試身手 ? 例 :利用一個可以顯示運行字符串的類 ,顯示自己的字符串 () applet code= width=300 heigh=200 param name=MESSAGE value=”this is a test param name=FONT value=BOLD param name=POINT_SIZE value=20/applet 18 小試身手 public void init() { String paramete。 parameter=getParameter(MESSAGE)。 if (parameter!=null) message=parameter。 parameter=getParameter(FONT)。 if (parameter!=null) font_to_use=parameter。 parameter=getParameter(POINT_SIZE)。 if (parameter!=null) point_size=(parameter)。 } 19 圖形處理 任何與繪圖有關(guān)的操作 第一個要用的是 Graphics類的對象不是 由 new產(chǎn)生的 ,而是由系 統(tǒng)或其他方式直接將生好的 Graphics對象當作方法的參數(shù) ,再交給程序設(shè)計者去處理 .例如 : paint(Graphics g) x y 0 20 圖形處理 ? Graphics的方法 paint(Graphics g) { ()。 ()。 () 。 ()。 ()。()。 ()。 ()。 ()。 ()。 ()。 ()。 () ()。 ()。 () () } 21 圖形處理 字型和顏色的設(shè)置 字型設(shè)置的方法 Font font=new Font(“TimesRoman”,24)。 (font)。 ? 在小應用程序中顯示輸出的方法 (String, int x, int y)。 (char data[], int offset, int length, int x, int y)。 22 圖形處理 (byte data[],int offset, int length, int x, int y)。 例 :(“This is a test”,5,10)。 ? 獲取字體的屬性 Font font=()。 ? Font類中常用的方法 GetFamily() getName() getSize() getStyle() isItalic() isPlain() isBold() toString() 23 圖形處理 import 。 import 。 public class drawtext extends { Font fn=new Font(TimesRoman,20)。 public void paint(Graphics g) { (fn)。 (”Font demo”,5,10)。 } } Font demo 24 圖形處理 ?獲取更詳細的數(shù)據(jù) 請查閱有關(guān) FontMetrics類的方法 fontMetrics=getFontMetrics(font)。 ?FontMetrics中比較重要的方法有 : stringWidth, charWidth, getAscent, getDescent, getLeading, getHeigh 25 圖形處理 顏色的調(diào)整 ? Color對象的使用 創(chuàng)造自己的顏色 : Color mycolor=new Color(int red, int blue, int green)。 ? () ? (mycolor)。 ? 例 :隨機產(chǎn)生顏色 ,并畫圓 26 圖形處理 import 。 import 。 public class drawcircle extends { public void paint(Graphics g) { int red,green,blue,x。 for (x=0。x370。x+=30){ red=(int)(()*256)。 green=(int)(()*256)。 blue=(int)(()*256)。 (new Color(red,green,blue))。 (x,0,30,30)。 }}} 27 URL類 構(gòu)造 URL類 (全名 ) ? 絕對 URL的構(gòu)造方法 : URL(String spec) 例 : URL url=new URL ( ? 相對 URL的構(gòu)造方法 : 某絕對地址 : 在該目錄下有兩個文件 28 URL類 URL base=new URL(“ URL url1=new (base, “”)。 URL url2=new (base, “”)。 ? 其他 URL的構(gòu)造方法 : URL url=new URL (“”, “”,“/~dyf/”)。 29 URL類 獲取小應用程序 HTML頁面的 URL和小應用程序本身的 URL ? URL html=getDocumentBase()。 ? (html)。 ? URL codebase=getCodeBase()。 ? (codebase)。 瀏覽器 服務器 html applet web page 30 URL類 ? URL異常 (MalformedURLException) 當創(chuàng)建 URL時發(fā)生錯誤 ,系統(tǒng)會產(chǎn)生異常
點擊復制文檔內(nèi)容
教學課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1