Skip to main content

[Solved]displaying an Image from an external URL

2 replies [Last post]
asterfr
Offline
Joined: 2008-07-17

Hello all,

I'm trying to display an image from a remote file. I've two question :

What is the simplest way to display an image ?

How can I get the image in the specific case of a remote file ?

Message was edited by: asterfr

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
from memory and you should probably handle exceptions/close on
finally to do this properly:

Form remote = new Form("Remote");
remote.setLayout(new BorderLayout());
InputStream i = Connector.openInputStream(url, Connector.READ);
Image img = Image.create(i);
i.close();
Label l = new Label(img);
remote.addComponent(BorderLayout.CENTER, img);
remote.show();

> Hello all,
>
> I'm trying to display an image from a remote file. I've two question :
>
> What is the simplest way to display an image ?
>
> How can I get the image in the specific case of a remote file ?
> [Message sent by forum member 'asterfr' (asterfr)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287340
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

asterfr
Offline
Joined: 2008-07-17

Thank you Shai :
If someone need, the exact code is :

InputStream i = Connector.openInputStream(this.getThumbnail());
Image img = Image.createImage(i);
i.close();
Label thumb = new Label(img);

Connector.READ isn't useful

Have a nice day !