Java JButton Settings getPressedButtonIcon(int x, int y)

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

Description

get Pressed Button Icon

License

Open Source License

Declaration

public static ImageIcon getPressedButtonIcon(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 final String IMAGE_FOLDER = "Images";
    private static final String PRESSED_BUTTON_IMAGE = "/ButtonPressed.png";

    public static ImageIcon getPressedButtonIcon(Dimension dim) {
        return getPressedButtonIcon(dim.width, dim.height);
    }/* www  .  j a va2 s.c  o  m*/

    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(AbstractButton b)
  2. getListenedButtonsFor(Container c)
  3. getMonospaceButton(final String text, final int size)
  4. getPreferredButtonSize(AbstractButton b, int textIconGap)
  5. getPreferredButtonSize(AbstractButton b, int textIconGap)
  6. getRadioButtonBorder(int fontSize, boolean ltr)
  7. getSelectedButton(ButtonGroup group)
  8. getSelectedButtonText(ButtonGroup buttonGroup)
  9. getSelectedButtonText(ButtonGroup buttonGroup)