About creating an Image [message #162376] |
Tue, 21 December 2004 16:14 |
Eclipse User |
|
|
|
Originally posted by: zhlmmc.hotmail.com
Why I have to create an Image in this way:
InputStream stream = MyPlugin.class.getResourceAsStream("shapes.gif");
Image image = new Image(null, stream);
try {
stream.close();
} catch (IOException ioe) {
}
If I write like this:
Image image = new Image(null,"shapes.gif");
will throw an exception?
thanks
|
|
|
Re: About creating an Image [message #162387 is a reply to message #162376] |
Tue, 21 December 2004 16:42 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Please post the exception and Image. Probably you should ask on SWT
newsgroup.
"zhlmmc" <zhlmmc@hotmail.com> wrote in message
news:cq9i5l$bnf$1@www.eclipse.org...
> Why I have to create an Image in this way:
> InputStream stream = MyPlugin.class.getResourceAsStream("shapes.gif");
> Image image = new Image(null, stream);
> try {
> stream.close();
> } catch (IOException ioe) {
> }
> If I write like this:
> Image image = new Image(null,"shapes.gif");
> will throw an exception?
>
> thanks
>
|
|
|
Re: About creating an Image [message #162456 is a reply to message #162387] |
Tue, 21 December 2004 23:54 |
Eclipse User |
|
|
|
Originally posted by: zhlmmc.hotmail.com
i/o exception FileNotFound
I put the .class and the .shapes in the same directory and my jface
application window can show the gif correctly,but my gef plugin throw
the exception.
Randy Hudson wrote:
> Please post the exception and Image. Probably you should ask on SWT
> newsgroup.
> "zhlmmc" <zhlmmc@hotmail.com> wrote in message
> news:cq9i5l$bnf$1@www.eclipse.org...
>> Why I have to create an Image in this way:
>> InputStream stream = MyPlugin.class.getResourceAsStream("shapes.gif");
>> Image image = new Image(null, stream);
>> try {
>> stream.close();
>> } catch (IOException ioe) {
>> }
>> If I write like this:
>> Image image = new Image(null,"shapes.gif");
>> will throw an exception?
>>
>> thanks
>>
|
|
|
|
Re: About creating an Image [message #162494 is a reply to message #162478] |
Wed, 22 December 2004 03:28 |
Eclipse User |
|
|
|
Originally posted by: zhlmmc.hotmail.com
I see...but could you tell me why my jface application can find the file?
I think I'm not clear about the mechanism of the plugin loader in Eclipse.
thanks :)
Cloudor Pu wrote:
> Of course you should get that exception. When you omit the path of the
> file name, it is assumed that your file is located in the directory your
> jvm started up rather than the directory which contains both your
> specified class and that image file.
> zhlmmc wrote:
>> i/o exception FileNotFound
>> I put the .class and the .shapes in the same directory and my jface
>> application window can show the gif correctly,but my gef plugin throw
>> the exception.
>>
>> Randy Hudson wrote:
>>
>>> Please post the exception and Image. Probably you should ask on SWT
>>> newsgroup.
>>> "zhlmmc" <zhlmmc@hotmail.com> wrote in message
>>> news:cq9i5l$bnf$1@www.eclipse.org...
>>>
>>>> Why I have to create an Image in this way:
>>>> InputStream stream = MyPlugin.class.getResourceAsStream("shapes.gif");
>>>> Image image = new Image(null, stream);
>>>> try {
>>>> stream.close();
>>>> } catch (IOException ioe) {
>>>> }
>>>> If I write like this:
>>>> Image image = new Image(null,"shapes.gif");
>>>> will throw an exception?
>>>>
>>>> thanks
>>>>
>>
>>
|
|
|
|
Re: About creating an Image [message #162519 is a reply to message #162502] |
Wed, 22 December 2004 05:18 |
Eclipse User |
|
|
|
Originally posted by: zhlmmc.hotmail.com
file:/D:/Program
Files/eclipse-SDK-3.0.1-win32/eclipse/workspace/HelloWorld/. /
file:/D:/Program Files/eclipse-SDK-3.0.1-win32/eclipse/./
It's clear now :)
Thank you!
Cloudor Pu wrote:
> I think it is because of your eclipse launcher set the working directory
> for your jface application. However, calling new Image(null, filename)
> is equivalent to calling new Image(null, new FileInputStream(
> filename)). You might want to print the URLs constructed by
> new File(".").toURL() in both applications to see the difference.
> zhlmmc wrote:
>> I see...but could you tell me why my jface application can find the file?
>> I think I'm not clear about the mechanism of the plugin loader in Eclipse.
>>
>> thanks :)
>> Cloudor Pu wrote:
>>
>>> Of course you should get that exception. When you omit the path of the
>>> file name, it is assumed that your file is located in the directory
>>> your jvm started up rather than the directory which contains both your
>>> specified class and that image file.
>>
>>
>>> zhlmmc wrote:
>>>
>>>> i/o exception FileNotFound
>>>> I put the .class and the .shapes in the same directory and my jface
>>>> application window can show the gif correctly,but my gef plugin throw
>>>> the exception.
>>>>
>>>> Randy Hudson wrote:
>>>>
>>>>> Please post the exception and Image. Probably you should ask on SWT
>>>>> newsgroup.
>>>>> "zhlmmc" <zhlmmc@hotmail.com> wrote in message
>>>>> news:cq9i5l$bnf$1@www.eclipse.org...
>>>>>
>>>>>> Why I have to create an Image in this way:
>>>>>> InputStream stream = MyPlugin.class.getResourceAsStream("shapes.gif");
>>>>>> Image image = new Image(null, stream);
>>>>>> try {
>>>>>> stream.close();
>>>>>> } catch (IOException ioe) {
>>>>>> }
>>>>>> If I write like this:
>>>>>> Image image = new Image(null,"shapes.gif");
>>>>>> will throw an exception?
>>>>>>
>>>>>> thanks
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03217 seconds