[J2SE]Japplet 不能用 icon?

看板java作者 (巧克力)時間17年前 (2008/03/12 15:08), 編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/1
就是japplet 的button扭 上有圖案時,我開瀏覽器看japplet,就無法顯示. 以下是程式馬: public class Imageicon extends JApplet{ Icon cion = new ImageIcon("T2.gif"); public void init(){ this.getContentPane().add(new JButton(cion)); } public void paint(Graphics g){ } } 請問大大們該怎麼在applet上的扭顯示出圖片.雖然在編譯的applet環境下可以看到圖片, 但瀏覽器去看applet時,就不行了. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.87.195.208

03/12 16:44, , 1F
直覺是路徑沒弄好。
03/12 16:44, 1F

03/12 18:08, , 2F
我有將gif html class 都放再同一個目錄
03/12 18:08, 2F

03/12 18:10, , 3F
在eclipse環境下run時看得到,但用瀏覽器看時看不到...
03/12 18:10, 3F

03/12 19:31, , 4F
後來用getClass().getResource("*.img") 才可以..好神奇..
03/12 19:31, 4F

03/12 21:37, , 5F
這.... 電腦裡頭沒有神奇的東西,只有神奇的 bug
03/12 21:37, 5F
文章代碼(AID): #17ru5mHw (java)