if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw.class.getResource(filename); if (url != null) if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw.class.getResource("/" + filename); if (url == null) throw new IllegalArgumentException("image " + filename + " not found");
/** * Overridden to return the status of the image loading operation of a wrapped ImageIcon, * or 0 if the contained icon is not an ImageIcon. * * @return the loading status as defined by java.awt.MediaTracker */ @Override public int getImageLoadStatus() { if (icon instanceof ImageIcon) { return ((ImageIcon) icon).getImageLoadStatus(); } return 0; }
/** * Overridden to return the status of the image loading operation of a wrapped ImageIcon, * or 0 if the contained icon is not an ImageIcon. * * @return the loading status as defined by java.awt.MediaTracker */ @Override public int getImageLoadStatus() { if (icon instanceof ImageIcon) { return ((ImageIcon) icon).getImageLoadStatus(); } return 0; }
private boolean isErrored() { return !(image instanceof ImageIcon) || ((ImageIcon) image).getImageLoadStatus() == MediaTracker.ERRORED; }
private boolean isErrored() { return !(image instanceof ImageIcon) || ((ImageIcon) image).getImageLoadStatus() == MediaTracker.ERRORED; }
ImageIcon ii = new ImageIcon(originalFile.getCanonicalPath()); if(ii.getImageLoadStatus() == MediaTracker.COMPLETE) { System.out.print("Load image ok\n"); } else { System.out.print("Load image failed\n"); }
/** * 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; } }
/** * Gets an image from the given filename. */ private static Image getImage (String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw3D.class.getResource(filename); if (url == null) throw new RuntimeException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
/************************************************************************* * Drawing images. *************************************************************************/ // get an image from the given filename private static Image getImage(String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw.class.getResource(filename); if (url == null) throw new IllegalArgumentException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
/************************************************************************* * Drawing images. *************************************************************************/ // get an image from the given filename private Image getImage(String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = Draw.class.getResource(filename); if (url == null) throw new RuntimeException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
/************************************************************************* * Drawing images. *************************************************************************/ // get an image from the given filename private static Image getImage(String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw.class.getResource(filename); if (url == null) throw new IllegalArgumentException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
@Override public int getImageLoadStatus() { return this.model.get().getImageLoadStatus(); }
/************************************************************************* * Drawing images. *************************************************************************/ // get an image from the given filename private Image getImage(String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = Draw.class.getResource(filename); if (url == null) throw new RuntimeException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
/** * Gets an image from the given filename. */ private static Image getImage (String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw3D.class.getResource(filename); if (url == null) throw new RuntimeException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
/*************************************************************************** * Drawing images. ***************************************************************************/ // get an image from the given filename private Image getImage(String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); icon = new ImageIcon(url); } catch (Exception e) { /* not a url */ } } // in case file is inside a .jar if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = Draw.class.getResource(filename); if (url == null) throw new IllegalArgumentException("image " + filename + " not found"); icon = new ImageIcon(url); } return icon.getImage(); }
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw.class.getResource(filename); if (url != null) if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { URL url = StdDraw.class.getResource("/" + filename); if (url == null) throw new IllegalArgumentException("image " + filename + " not found");
/** * Gets the IconBox for the specified image IRI. * * @param iri The IRI pointing to the image. * @return The icon box containing the image. * @throws MalformedURLException */ private IconBox getImageBox(IRI iri) throws MalformedURLException, IllegalArgumentException { ImageIcon imageIcon = new ImageIcon(iri.toURI().toURL()); imageIcon.getImageLoadStatus(); IconBox iconBox = new IconBox(imageIcon, new HTTPLink(iri.toURI())); iconBox.setMaxHeight(50); return iconBox; }
/** * Gets the IconBox for the specified image IRI. * * @param iri The IRI pointing to the image. * @return The icon box containing the image. * @throws MalformedURLException */ private IconBox getImageBox(IRI iri) throws MalformedURLException, IllegalArgumentException { ImageIcon imageIcon = new ImageIcon(iri.toURI().toURL()); imageIcon.getImageLoadStatus(); IconBox iconBox = new IconBox(imageIcon, new HTTPLink(iri.toURI())); iconBox.setMaxHeight(50); return iconBox; }
public Splash(JFrame f, String progName, String fileName) { super(); // Can't use Swing border on JWindow: not a JComponent. // setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); im = new ImageIcon(fileName); if (im.getImageLoadStatus() != MediaTracker.COMPLETE) JOptionPane.showMessageDialog(f, "Warning: can't load image " + fileName + "\n" + "Please be sure you have installed " + progName + " correctly", "Warning", JOptionPane.WARNING_MESSAGE); int w = im.getIconWidth(), h = im.getIconHeight(); setSize(w, h); UtilGUI.center(this); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { dispose(); } }); addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { dispose(); } }); }
public Splash(JFrame f, String progName, String fileName) { super(); // Can't use Swing border on JWindow: not a JComponent. // setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); im = new ImageIcon(fileName); if (im.getImageLoadStatus() != MediaTracker.COMPLETE) JOptionPane.showMessageDialog(f, "Warning: can't load image " + fileName + "\n" + "Please be sure you have installed " + progName + " correctly", "Warning", JOptionPane.WARNING_MESSAGE); int w = im.getIconWidth(), h = im.getIconHeight(); setSize(w, h); UtilGUI.center(this); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { dispose(); } }); addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { dispose(); } }); }