Java Utililty Methods ImageIcon

List of utility methods to do ImageIcon

Description

The list of methods to do ImageIcon are organized into topic(s).

Method

voidpaintWithWatermarkHelper(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();
...
ImageIconparseImageIcon(Image image)
Convierte un objeto Image en un objeto ImageIcon
return new ImageIcon(image);
ImageIconprepareImage(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);
voidsaveImage(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();
voidsetDefaultImageIcons(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)) {
...
ImageIconsetImageIcon(ImageIcon icon, String description)
set Image Icon
if (icon == null)
    return icon;
icon.setDescription(description);
return icon;
voidsetImageIcon(JLabel label, URL url)
set Image Icon
if (url != null) {
    label.setIcon(new ImageIcon(url));
} else {
    label.setIcon(null);
IconSetStandardSizeForImage(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;
voidsetVerBumpIcon(ImageIcon icon)
set Ver Bump Icon
verBumpIcon = icon;
JWindowshowLogo(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());
...