List of utility methods to do ImageIcon
void | paintWithWatermarkHelper(JComponent component, ImageIcon watermark, Graphics g) A helper function to paint a watermark for a component. Graphics2D g2 = (Graphics2D) g; Paint oldPaint = g2.getPaint(); g2.setPaint(component.getBackground()); try { g2.fillRect(0, 0, component.getWidth(), component.getHeight()); if (watermark != null) { Rectangle viewRect = new Rectangle(0, 0, component.getWidth(), component.getHeight()); Component parent = component.getParent(); ... |
ImageIcon | parseImageIcon(Image image) Convierte un objeto Image en un objeto ImageIcon return new ImageIcon(image); |
ImageIcon | prepareImage(ImageIcon icon, int x, int y) prepare Image Image img = icon.getImage(); Image newImg = img.getScaledInstance(x, y, java.awt.Image.SCALE_SMOOTH); return new ImageIcon(newImg); |
void | saveImage(ImageIcon picture, String targetfile) Save image. BufferedImage img = toBufferedImage(picture.getImage()); String image_format = "png"; FileOutputStream out = new FileOutputStream(targetfile); javax.imageio.ImageIO.write(img, image_format, out); out.close(); |
void | setDefaultImageIcons(Window window) set Default Image Icons Icon icon = UIManager.getIcon("Window.icon"); if (icon instanceof ImageIcon) { window.setIconImage(((ImageIcon) icon).getImage()); Object icons = UIManager.getDefaults().get("Window.icons"); if (icons instanceof List<?>) { List<Image> iconList = new ArrayList<Image>(); for (Object ico : ((List<?>) icons)) { ... |
ImageIcon | setImageIcon(ImageIcon icon, String description) set Image Icon if (icon == null) return icon; icon.setDescription(description); return icon; |
void | setImageIcon(JLabel label, URL url) set Image Icon if (url != null) { label.setIcon(new ImageIcon(url)); } else { label.setIcon(null); |
Icon | SetStandardSizeForImage(ImageIcon icon) Set Standard Size For Image Image img = icon.getImage(); BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); g.drawImage(img, 0, 0, 50, 50, null); Icon newIcon = new ImageIcon(bi); return newIcon; |
void | setVerBumpIcon(ImageIcon icon) set Ver Bump Icon verBumpIcon = icon; |
JWindow | showLogo(ImageIcon logo) Shows the given Image as a logo on a simple window JWindow logoWin = new JWindow(); JLabel jl = new JLabel(logo); JPanel jp = new JPanel(); jp.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED)); jp.add(jl); jp.setSize(jl.getPreferredSize()); logoWin.setContentPane(jp); logoWin.setSize(jp.getPreferredSize()); ... |