Here you can find the source of loadImage(URL url)
Parameter | Description |
---|---|
url | the URL of the image to load. |
Parameter | Description |
---|---|
InterruptedException | an exception |
public static Image loadImage(URL url) throws InterruptedException
//package com.java2s; /*/*from w w w . jav a 2s . c om*/ * Scriptographer * * This file is part of Scriptographer, a Scripting Plugin for Adobe Illustrator * http://scriptographer.org/ * * Copyright (c) 2002-2010, Juerg Lehni * http://scratchdisk.com/ * * All rights reserved. See LICENSE file for details. * * File created on May 11, 2007. */ import java.awt.Image; import java.awt.MediaTracker; import java.net.URL; public class Main { /** * Load an image from a given URL. This blocks until the image is * loaded or an error occured. * @param url the URL of the image to load. * @return the loaded image * @throws InterruptedException */ public static Image loadImage(URL url) throws InterruptedException { MediaTracker tracker = new MediaTracker(new java.awt.Container()); Image img = java.awt.Toolkit.getDefaultToolkit().createImage(url); tracker.addImage(img, 0); tracker.waitForAll(); return img; } }