Re: [問題] java裡怎麼用label顯示圖片

看板java作者 (shooting star)時間18年前 (2006/05/11 13:22), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/9 (看更多)
※ 引述《loveng (楓葉)》之銘言: : 在java裡使用awt套件 : 顯示文字的話是Label lbl = new Label("Hello") : 那如果是要顯示圖片呢? : Label lb2 = new Label("000.jpg"); 是錯的,不能這樣寫 : 因為這樣顯示出來的是000.jpg這文字,而不是圖片 : 所以不知道要怎麼寫,請會的人教一下,謝謝喔^^ ............................................. 煩請多多查查API吧 awt套件裡的 Label 類別,我沒看到可以傳一張圖片的檔案路徑 為參數的建構子 而且下面一段話擷取自 Label 的API: A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly. 也就是說他只能顯示文字而已 swing裡面的 JLabel 才可以顯示圖片 至於用法....請去查查API吧 http://java.sun.com/j2se/1.4.2/docs/api/ 對了,順便說一下 JLabel label = new JLabel("000.jpg"); 這樣可是不行的喔 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.96.181
文章代碼(AID): #14OieE6g (java)
討論串 (同標題文章)
文章代碼(AID): #14OieE6g (java)