List of utility methods to do Swing Icon
Icon | getIconFromExtension(String f, boolean folder) get Icon From Extension if (folder) { return getFolderIcon(); } else { return getIconFromExtension(f); |
ImageIcon | getIconInterTrial() get Icon Inter Trial if (ICON_INTERTRIAL == null) { File iconInterTrialFile = new File("icons" + File.separator + "intertrial.png"); try { ICON_INTERTRIAL = new ImageIcon(iconInterTrialFile.toURI().toURL()); } catch (MalformedURLException e) { e.printStackTrace(); return ICON_INTERTRIAL; |
Image | getIcono() Imagen de icono para la ventana principal URL urlDeLaImagen = Main.class.getClassLoader().getResource("images/icon.png"); ImageIcon img = new ImageIcon(urlDeLaImagen); return img.getImage(); |
ImageIcon | getPressedExitIcon(int x, int y) get Pressed Exit Icon if (PressedExit == null) { PressedExit = new ImageIcon(IMAGE_FOLDER + PRESSED_EXIT_IMAGE); return prepareImage(PressedExit, y, x); |
Icon | getResourceIcon(Object target, String name) { method return (getResourceIcon(target.getClass(), name));
|
ImageIcon | getScaledIcon(Icon icon) Get a scaled icon starting from an icon. int iconWidth = icon.getIconWidth(); int iconHeight = icon.getIconHeight(); int scale = 2; int scaledIconWidth = iconWidth / scale; int scaledIconHeight = iconHeight / scale; BufferedImage bufferedImage = new BufferedImage(scaledIconWidth, scaledIconHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics2D = bufferedImage.createGraphics(); ... |
Icon | getScaledIcon(Icon tmpIcon, int w, int h, boolean incr) get Scaled Icon ImageIcon ii = null; if (tmpIcon instanceof ImageIcon) { return getScaledImageIcon((ImageIcon) tmpIcon, w, h, incr); return tmpIcon; |
ImageIcon | getScaledIcon(String resourceName, int width, int height) Used to get an icon with specified width and height. ImageIcon result = getImageIcon(resourceName); if (result != null) { if (width > 0 && height > 0) { Image artImage = result.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH); result.setImage(artImage); return result; ... |
int[] | getSize(String graphIconPath) Retrieve image size's if (graphIconPath != null && !graphIconPath.isEmpty()) { ImageIcon image = new ImageIcon(graphIconPath); return new int[] { image.getIconWidth(), image.getIconHeight() }; } else { return new int[] { 150, 75 }; |
ImageIcon | getTransparentIcon(int width) get Transparent Icon switch (width) { case ICON_SIZE_SMALL: return ICON_TRANSPARENT_SMALL; case ICON_SIZE_MEDIUM: return ICON_TRANSPARENT_MEDIUM; case ICON_SIZE_LARGE: return ICON_TRANSPARENT_LARGE; default: ... |