当前位置: 首页>>代码示例>>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;未经允许,请勿转载。