List of utility methods to do Swing Icon
Icon | getDefaultIcon() get Default Icon BufferedImage bi = new BufferedImage(18, 18, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g2 = bi.createGraphics(); g2.setBackground(Color.red); g2.clearRect(0, 0, bi.getWidth(), bi.getHeight()); g2.setColor(Color.white); g2.setStroke(new BasicStroke(2)); GeneralPath x = new GeneralPath(); x.moveTo(0, 0); ... |
ImageIcon | getEmptyIcon() Returns the ImageIcon for the empty icon. return getIcon(EMPTY_ICON);
|
ImageIcon | getFolderIcon() get Folder Icon return new ImageIcon("resources/images/folder.png"); |
Icon | getFolderIcon() Gets system default folder icon Icon icon; if (CACHE.containsKey("file-dir")) { icon = CACHE.get("file-dir"); } else { File temp = new File(System.getProperty("java.io.tmpdir") + File.separator + "icon"); temp.mkdirs(); icon = FileSystemView.getFileSystemView().getSystemIcon(temp); CACHE.put("file-dir", icon); ... |
Icon | getIcon(boolean isPressed, Icon baseIcon_) get Icon BufferedImage img = new BufferedImage(baseIcon_.getIconWidth(), baseIcon_.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = img.getGraphics(); baseIcon_.paintIcon(TEMP, g, 0, 0); g.dispose(); for (int i = 0; i < img.getWidth(); i++) { for (int j = 0; j < img.getHeight(); j++) { Color rgba = new Color(img.getRGB(i, j), true); ... |
ImageIcon | getIcon(Class baseclass, String name) E.g. try { return new ImageIcon(baseclass.getResource("images/" + name)); } catch (NullPointerException e) { e.printStackTrace(); return null; |
ImageIcon | getIcon(Class> clazz, String path) get Icon return (new ImageIcon(clazz.getResource(path))); |
ImageIcon | getIcon(final String path) Create an icon from the resource at path. return new ImageIcon(Thread.currentThread().getContextClassLoader().getResource(path)); |
ImageIcon | getIcon(final String resource) Load an icon for the given resource file. URL url = Thread.currentThread().getContextClassLoader().getResource(resource); if (url == null) return null; return new ImageIcon(url); |
Icon | getIcon(int index) This function returns the icon at a specific index if (index >= 0 && index < icons.size()) { return icons.get(index); return null; |