List of usage examples for java.awt MediaTracker isErrorAny
public synchronized boolean isErrorAny()
From source file:SlidePuzzle.java
public void run() { if (!m_fAllLoaded) { m_Graphics = getGraphics(); MediaTracker tracker = new MediaTracker(this); logo = getImage(getDocumentBase(), "vjlogo.gif"); tracker.addImage(logo, 0);/* w w w .j a v a 2 s. c o m*/ try { tracker.waitForAll(); m_fAllLoaded = !tracker.isErrorAny(); } catch (InterruptedException e) { } if (!m_fAllLoaded) { stop(); m_Graphics.drawString("Error loading images!", 10, 40); return; } } //Clear the screen and draw first image repaint(); //Move the squares while (true) { for (x = 1; x < 9; x++) { //Slow down the animation try { Thread.sleep(350); } catch (InterruptedException e) { } //Move square to next location m_Graphics.copyArea(squares[order[x]].x, squares[order[x]].y, 60, 60, squares[order[x - 1]].x - squares[order[x]].x, squares[order[x - 1]].y - squares[order[x]].y); //Clear most recently copied square m_Graphics.clearRect(squares[order[x]].x, squares[order[x]].y, 60, 60); } //Repaint original graphic after two cycles y++; if (y == 2) { repaint(); y = 0; } } }
From source file:net.sf.firemox.tools.MToolKit.java
/** * Return the loaded picture from a local place. * // w w w. j av a 2 s . c o m * @param localFile * the local file name. * @return the local picture. * @throws InterruptedException */ public static Image getLocalPicture(String localFile) throws InterruptedException { final Image result = Toolkit.getDefaultToolkit().getImage(getFile(localFile, true).getAbsolutePath()); if (result == null) { throw new InterruptedException("Picture " + localFile + " has not been found"); } final MediaTracker tracker = new MediaTracker(MagicUIComponents.magicForm); tracker.addImage(result, 0); tracker.waitForAll(); if (tracker.isErrorAny()) { tracker.removeImage(result, 0); tracker.waitForAll(); result.flush(); throw new InterruptedException("Malformed picture " + localFile); } return result; }