作者H45 (!H45)
看板java
标题Re: [J2ME] Image.createImage(String name)的问题
时间Mon Nov 20 22:57:57 2006
※ 引述《Nessie0924 (雷声将季节切了开)》之铭言:
: 不好意思,想请问一下,在J2ME中,我按照书上的范例输入:
: ....(前略;不过下面的部分是在一个extends Canvas的物件里)
: Image source;
: Image copy;
: // constructor; 名称略过,下面是建构子内容;
: try{
: source = Image.createImage("/picture_name.png");
: ....
: }
: ......(後略)
: 在执行时会在标色那一行丢出IOException,我已经把图片放在和.java同一个目
: 录底下,仍无法正确执行,请问,这是什麽问题呢?
: 图片是书上的范例附的,应该是可以开启才对;我用的模拟器是WTK 2.2版里的
: DefaultColorPhone。
java.lang.Class.getResourceAsStream
Before delegation, an absolute resource name is constructed from the given
resource name using this algorithm:
* If the name begins with a '/' ('\u002f'), then the absolute name of
the resource is the portion of the name following the '/'.
* Otherwise, the absolute name is of the following form:
modified_package_name/name
Where the modified_package_name is the package name of this object with
'/' substituted for '.' ('\u002e').
我想应该是图片的位置不对吧
也许上面这段说明能帮上你的忙
Ref: J2ME lcdui API, J2SE API
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.205.85