-1

Could you tell me how can I download image from Url (ex: from "http://www.google.ru/intl/en_com/images/logo_plain.png") to JLabel but without saving it on HDD?

Could you give me an easy example? All I need is to put the image from the URL to JLabel (with ImageIO for ex.)

4

2 回答 2

2

就像是

JLabel label = new JLabel(new ImageIcon(ImageIO.read(new URL("http://www.google.ru/intl/en_com/images/logo_plain.png")));

这会引发一些异常,所以要小心

于 2012-12-17T19:26:55.757 回答
2

由于您似乎不需要使用 ImageIO,即使您多次提到它,这是我所知道的最简单的方法:

label = new JLabel(new ImageIcon(new URL(urlString)));
于 2012-12-17T19:35:34.760 回答