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

正文內(nèi)容

北大計(jì)算機(jī)系java講義--第二章java小程序(編輯修改稿)

2025-07-03 18:44 本頁面
 

【文章內(nèi)容簡介】 try{ URL url=new URL(str)。 }catch(MalformedURLException( e) { DisplayErrorMessage()。} ? URL類的基本方法 String getProtocol(), String getHost(), ing getPort(), String getFile(), String getRef() 31 URL類 ? 構(gòu)造 URL的實(shí)例 import 。 import 。 public class Test { URL url1,url2,url3。 void test() { try { url1= new URL(“file:/D:/image/”)。 url2= new URL(“ url1= new URL(url2, “”)。 }catch (MalformedURLException e)。 //處理例外 } }} 32 載入現(xiàn)有圖像文件 Image類 ? java支持 gif和 jpg兩種格式的圖像 ? 圖像文件的 URL: URL picurl= new URL (“ ? 取一幅圖像構(gòu)成圖像對象 Image img1 = getImage(picurl)。 Image img2 = getImage(getCodeBase(), “”)。 33 載入現(xiàn)有圖像文件 ? 顯示一幅圖像 : (img1, x, y, this)。 (img1, x, y, this)。 (image1, x, y,x2,y2, this)。 規(guī)定背景 規(guī)定尺寸 34 載入現(xiàn)有圖像文件 ? 完整的過程 不要忘記 AWT包 定義 Image對象了嗎 ? 指定圖像的 URL了嗎 ? 把圖像取出來吧 . 還記得畫圖像用什么方法和命令嗎 ? 在類中 在 init0中 在 paint0中 35 載入現(xiàn)有圖像文件 import .*。import .*。 public class image extends Applet { Image img。 public void init() { img=getImage(getCodeBase(),)。} public void paint(Graphics g) { int width=(this)。 int height=(this)。 (52,52,width+30,height+30)。 (img,57,57,width+20,height+20,this)。}} 36 動態(tài)效果 線程的應(yīng)用 動態(tài)效果 線程的應(yīng)用 ? 什么是線程 ? 線程是執(zhí)行中的程序中的單個順序控制流 . ? Java支持多線程 開始 顯示進(jìn)度 引出最后結(jié)果 數(shù)學(xué)運(yùn)算 線程 1 線程 2 37 動態(tài)效果 線程的應(yīng)用 ? 靜態(tài)的情況 import .*。 import 。 public class maguee extends Applet { public void paint(Graphics g) { (Hello, Java!,0,0)。 } } 38 動態(tài)效果 線程的應(yīng)用 ? 動態(tài)的情況 (不是多線程 ) public void init() { x=size().width。 y=size().height/2。 width=x。 } public void paint(Graphics g) { while(true) { (Hello, Java!,x,y)。 x=10。 if(x0) x=width。 } } 39 動態(tài)效果 線程的應(yīng)用 ? 實(shí)現(xiàn)一個線程 讓 Applet類去實(shí)現(xiàn) Runable接口 ,創(chuàng)建一個線程類 改寫方法 start,在其中產(chǎn)生一個新的線程來工作 改寫 stop方法 ,在其中編寫結(jié)束線程的程序代碼 引入新的方法 ,將分給線程的工作寫到 run中 40 動態(tài)效果 線程的應(yīng)用 第一步:實(shí)現(xiàn) Runable接口 public class xc extends implements Runnable { Thread smallthread=null。 … } Thread是一個類 ,只有是它的實(shí)例才能具有線程的功能 主函數(shù)中要定義一個線程變量 41 動態(tài)效果 線程的應(yīng)用 第二步:改寫方法 start public void start() { if( smallthread == null) { smallthread= new Thread( this); ()。 //從現(xiàn)在開始程序由兩個線程在執(zhí)行 }} 第三步:改寫 stop方法 public void stop() { ()。 //停止線程 smallthread = null。 //釋放線程對象 } 42 動態(tài)效果 線程的應(yīng)用 第四步 :新的方法 run 將讓線程要做的事放 run中 public void run() { while (true) { repaint()。 try {(1000)。} catch(InterruptedException e){} } } 43 動態(tài)效果 線程的應(yīng)用 import .*。 import 。 public class MovingCharacter extends Applet implements Runnable { int x=200。 Thread my_thread=null。 // public void start() { my_thread=new Thread(this)。 ()。 } public void run() {
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1