作者NightPrince (shooting star)
看板java
标题Re: [问题] java里怎麽用label显示图片
时间Thu May 11 13:29:30 2006
※ 引述《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