當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaTracker.LOADING屬性代碼示例

本文整理匯總了Java中java.awt.MediaTracker.LOADING屬性的典型用法代碼示例。如果您正苦於以下問題:Java MediaTracker.LOADING屬性的具體用法?Java MediaTracker.LOADING怎麽用?Java MediaTracker.LOADING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.MediaTracker的用法示例。


在下文中一共展示了MediaTracker.LOADING屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displaySplashScreen

/**
 * Displays splash.png during the loading
 * @return 
 */
public SplashScreen displaySplashScreen() {
	ImageIcon splashScreenImage = new ImageIcon();
	try {
		splashScreenImage.setImage(ImageIO.read(getClass().getResource(
				"splash.png")));
	} catch (IOException e1) {
		e1.printStackTrace();
	}
	// while the image is not on screen
	while (splashScreenImage.getImageLoadStatus() == MediaTracker.LOADING) {
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			System.out.printf("splash screen loading interrupted", e); //$NON-NLS-1$
		}
	}
	// should normally be run in the EDT, but launched at once in order to
	// display the screen as soon as possible
	return  new SplashScreen(splashScreenImage, 2000, version);
}
 
開發者ID:Neonunux,項目名稱:calao,代碼行數:24,代碼來源:Calao.java

示例2: loadImage

public static Image loadImage(String filename, Component watcher, URL url) {
    Image image = null;

    if (url == null) {
        System.err.println("loadImage() could not find \"" + filename + "\"");
    } else {
        image = watcher.getToolkit().getImage(url);
        if (image == null) {
            System.err.println("loadImage() getImage() failed for \"" + filename + "\"");
        } else {
            MediaTracker tracker = new MediaTracker(watcher);

            try {
                tracker.addImage(image, 0);
                tracker.waitForID(0);
            } catch (InterruptedException e) {
                System.err.println("loadImage(): " + e);
            } finally {
                boolean isError = tracker.isErrorAny();
                if (isError) {
                    System.err.println("loadImage() failed to load \"" + filename + "\"");
                    int flags = tracker.statusAll(true);

                    boolean loading = 0 != (flags & MediaTracker.LOADING);
                    boolean aborted = 0 != (flags & MediaTracker.ABORTED);
                    boolean errored = 0 != (flags & MediaTracker.ERRORED);
                    boolean complete = 0 != (flags & MediaTracker.COMPLETE);
                    System.err.println("loading: " + loading);
                    System.err.println("aborted: " + aborted);
                    System.err.println("errored: " + errored);
                    System.err.println("complete: " + complete);
                }
            }
        }
    }

    return image;
}
 
開發者ID:addertheblack,項目名稱:myster,代碼行數:38,代碼來源:Util.java

示例3: getLoadedImage

/**
 * Ensures the image is loaded enough (loading is fine).
 * 
 * @param newImage to check
 * @return image or null if not loaded enough.
 */
private Image getLoadedImage(final Image newImage) {
    final ImageIcon imageLoader = new ImageIcon(newImage);
    switch (imageLoader.getImageLoadStatus()) {
        case MediaTracker.LOADING:
        case MediaTracker.COMPLETE:
            return imageLoader.getImage();
        default:
            return null;
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:16,代碼來源:PImage.java

示例4: getImage

/**
 * Loads a cached image from a class offset from the ImageManager
 * waiting for it to be completely loading using a MediaTracker
 * @param imageName the name of the image to load
 * @return the cached image
 */
public ImageIcon getImage(String imageName) {
	ImageIcon image = null;

	if (images.containsKey(imageName)) {
		image = (ImageIcon) images.get(imageName);
	} else {
		URL url = getClass().getResource(imageName);

		if (url == null) {
			//System.out.println("ImageManager.getImage() could not find image: " + imageName);
		} else {
			image = new ImageIcon(getClass().getResource(imageName));

			while (image.getImageLoadStatus() == MediaTracker.LOADING) {
				try {
					Thread.currentThread().wait(100);
				} catch (InterruptedException e) {
				}
			}

			if (image != null && image.getImageLoadStatus() == MediaTracker.COMPLETE) {
				images.put(imageName, image);
			} else {
				//System.out.println("ImageManager.getImage() failed to load image: " + imageName);
			}
		}
	}

	return image;
}
 
開發者ID:mongkoy,項目名稱:c-logger,代碼行數:36,代碼來源:ImageManager.java

示例5: getImage

/**
 * Loads a cached image from a class offset from the ImageManager waiting for it to be completely loading using a
 * MediaTracker
 * @param imageName the name of the image to load
 * @return the cached image
 */
public ImageIcon getImage(String imageName)
{
    ImageIcon image = null;

    if (images.containsKey(imageName))
    {
        image = (ImageIcon) images.get(imageName);
    }
    else
    {
        URL url = getClass().getResource(imageName);

        if (url != null)
        {
            image = new ImageIcon(getClass().getResource(imageName));

            while (image.getImageLoadStatus() == MediaTracker.LOADING)
            {
                try
                {
                    Thread.currentThread().wait(100);
                }
                catch (InterruptedException e)
                {

                }
            }

            if (image != null && image.getImageLoadStatus() == MediaTracker.COMPLETE)
            {
                images.put(imageName, image);
            }
        }
    }

    return image;
}
 
開發者ID:joshpassenger,項目名稱:jfreestock,代碼行數:43,代碼來源:ImageManager.java


注:本文中的java.awt.MediaTracker.LOADING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。