@NotNull @Override protected String compute() { final Class<JavaFxHtmlPanel> clazz = JavaFxHtmlPanel.class; //noinspection StringBufferReplaceableByString return new StringBuilder() .append("<script src=\"") .append(clazz.getResource("scrollToElement.js")) .append("\"></script>\n") .append("<script src=\"") .append(clazz.getResource("processLinks.js")) .append("\"></script>\n") .toString(); }
/** * Create a splash screen (borderless graphic for display while other operations are taking * place). * * @param filename a class-relative path to the splash graphic * @param callingClass the class to which the graphic filename location is relative */ public SplashScreen(String filename, Class callingClass) { super(new Frame()); URL imageURL = callingClass.getResource(filename); image = Toolkit.getDefaultToolkit().createImage(imageURL); // Load the image MediaTracker mt = new MediaTracker(this); mt.addImage(image, 0); try { mt.waitForID(0); } catch (InterruptedException ie) { } // Center the window on the screen int imgWidth = image.getWidth(this); int imgHeight = image.getHeight(this); setSize(imgWidth, imgHeight); Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((screenDim.width - imgWidth) / 2, (screenDim.height - imgHeight) / 2); setVisible(true); repaint(); // if on a single processor machine, wait for painting (see Fast Java Splash Screen.pdf) if (!EventQueue.isDispatchThread()) { synchronized (this) { while (!this.paintCalled) { try { this.wait(); } catch (InterruptedException e) { } } } } }
/** * Returns icon for the specified name. * * @param icon can be either String icon name, ImageIcon, Image, image File or image URL * @return icon for the specified name */ public ImageIcon getIcon(final Object icon) { if (icon != null) { if (icon instanceof String) { try { if (nearClass != null) { return new ImageIcon(nearClass.getResource(path + icon + extension)); } else { return new ImageIcon(new File(path, icon + extension).getAbsolutePath()); } } catch (final Throwable e) { Log.warn("Unable to find menu icon for path: " + path + icon + extension, e); return null; } } else if (icon instanceof ImageIcon) { return (ImageIcon) icon; } else if (icon instanceof Image) { return new ImageIcon((Image) icon); } else if (icon instanceof File) { return new ImageIcon(((File) icon).getAbsolutePath()); } else if (icon instanceof URL) { return new ImageIcon((URL) icon); } else { Log.warn("Unknown icon object type provided: " + icon); return null; } } else { return null; } }
@Nullable public static Icon findIcon( @NotNull String path, @NotNull final Class aClass, boolean computeNow) { path = undeprecate(path); if (isReflectivePath(path)) return getReflectiveIcon(path, aClass.getClassLoader()); URL myURL = aClass.getResource(path); if (myURL == null) { if (STRICT) throw new RuntimeException("Can't find icon in '" + path + "' near " + aClass); return null; } return findIcon(myURL); }
private Object getResource(String key) { URL url = null; String name = key; if (name != null) { try { Class c = Class.forName("content.AdvancedPanel"); url = c.getResource(name); } catch (ClassNotFoundException cnfe) { System.err.println("Unable to find Main class"); } return url; } else return null; }