Here you can find the source of urlToImage(String urlstring)
Parameter | Description |
---|---|
urlstring | The url of the image. |
public static Image urlToImage(String urlstring)
//package com.java2s; /*/*from ww w. ja v a 2s . c o m*/ * This file is part of CraftCommons. * * Copyright (c) 2011 CraftFire <http://www.craftfire.com/> * CraftCommons is licensed under the GNU Lesser General Public License. * * CraftCommons is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * CraftCommons is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.Image; import java.awt.Toolkit; import java.net.MalformedURLException; import java.net.URL; public class Main { /** * @param urlstring The url of the image. * @return Image object. */ public static Image urlToImage(String urlstring) { try { URL url = new URL(urlstring); return Toolkit.getDefaultToolkit().createImage(url); } catch (MalformedURLException e) { e.printStackTrace(); } return null; } }