Java Swing Icon getPressedExitIcon(int x, int y)

Here you can find the source of getPressedExitIcon(int x, int y)

Description

get Pressed Exit Icon

License

Open Source License

Declaration

public static ImageIcon getPressedExitIcon(int x, int y) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Dimension;
import java.awt.Image;
import javax.swing.ImageIcon;

public class Main {
    private static ImageIcon PressedButton = null;
    private static ImageIcon PressedExit = null;
    private static final String IMAGE_FOLDER = "Images";
    private static final String PRESSED_BUTTON_IMAGE = "/ButtonPressed.png";
    private static final String PRESSED_EXIT_IMAGE = "/ExitButton2.png";

    public static ImageIcon getPressedExitIcon(Dimension dim) {
        return getPressedButtonIcon(dim.width, dim.height);
    }/*from w w w .j ava2  s  .  com*/

    public static ImageIcon getPressedExitIcon(int x, int y) {
        if (PressedExit == null) {
            PressedExit = new ImageIcon(IMAGE_FOLDER + PRESSED_EXIT_IMAGE);
        }
        return prepareImage(PressedExit, y, x);
    }

    public static ImageIcon getPressedButtonIcon(Dimension dim) {
        return getPressedButtonIcon(dim.width, dim.height);
    }

    public static ImageIcon getPressedButtonIcon(int x, int y) {
        if (PressedButton == null) {
            PressedButton = new ImageIcon(IMAGE_FOLDER + PRESSED_BUTTON_IMAGE);
        }
        return prepareImage(PressedButton, x, y);
    }

    private static ImageIcon prepareImage(ImageIcon icon, int x, int y) {
        Image img = icon.getImage();
        Image newImg = img.getScaledInstance(x, y, java.awt.Image.SCALE_SMOOTH);
        return new ImageIcon(newImg);
    }
}

Related

  1. getIcon(String name, ClassLoader classLoader)
  2. getIconCheckBox(String iconPath, String pressIconPath, String rolloverIconPath, String selectedIconPath)
  3. getIconFromExtension(String f, boolean folder)
  4. getIconInterTrial()
  5. getIcono()
  6. getResourceIcon(Object target, String name)
  7. getScaledIcon(Icon icon)
  8. getScaledIcon(Icon tmpIcon, int w, int h, boolean incr)
  9. getScaledIcon(String resourceName, int width, int height)