title: How do I fade the edges of an image in Java? (example given)
body: <p>I am currently in the middle of a project in which I have to grayscale, blue filter, red filter, green filter, and fade the edges of a picture of a cat at the press of a JButton. grayscale and color filtering the picture was easy, but I can't seem to figure out how to fade the image's edges to black.</p>
  
  <p>What I mean by this, is I have this picture of the cat I need to change:</p>
  
  <p><a href="https://i.stack.imgur.com/TVnLs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TVnLs.png" alt="the cat I need to change"></a> </p>
  
  <p>and I need to change it into something like this one:</p>
  
  <p><a href="https://i.stack.imgur.com/RJ9yF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RJ9yF.png" alt="this one."></a></p>
  
  <pre><code>    import javax.imageio.ImageIO;
      import javax.swing.JButton;
      import javax.swing.JPanel;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.ImageIcon;
      import java.awt.image.BufferedImage;
      import java.io.File;
      import java.io.IOException; 
  
      public class GUIKittenPicJC {
          public static class KittenChanger extends JPanel {
                  BufferedImage img = null;
                  File Kitten = null;
                  ImageIcon imagetransformed = null;
                  JButton grayscale = new JButton("Grayscale Image");
                  JButton rgbB = new JButton("Blue filter this image");
                  JButton rgbR = new JButton("Red filter this image");
                  JButton rgbG = new JButton("Green filter this image");
                  JButton fader = new JButton("Fade this image");
                  {
                  try
                  {
                      Kitten = new File("C:\\Users\\Jarrod\\Desktop\\Lab 3\\Lab 3\\kitten.bmp");
                      img = ImageIO.read(Kitten);
                  }
                  catch(IOException e)
                  {
                    System.out.println(e);
                  }
              ImageIcon image = new ImageIcon(img);
              JLabel imageLabel = new JLabel(image);
              add(imageLabel);
              grayscale.addActionListener(e-&gt;{
                         imagetransformed = new ImageIcon(Grayscale(img));
                         imageLabel.setIcon(imagetransformed);
                         imgReset();
                      });
              rgbB.addActionListener(e-&gt;{
                     imagetransformed = new ImageIcon(Bluify(img));
                     imageLabel.setIcon(imagetransformed);
                     imgReset();
                  });
              rgbG.addActionListener(e-&gt;{
                     imagetransformed = new ImageIcon(Greenify(img));
                     imageLabel.setIcon(imagetransformed);
                     imgReset();
                  });
              rgbR.addActionListener(e-&gt;{
                     imagetransformed = new ImageIcon(Redify(img));
                     imageLabel.setIcon(imagetransformed);
                     imgReset();
                  });
                          add(grayscale);
                          add(rgbB);
                          add(rgbG);
                          add(rgbR);
                  }
                  private void imgReset() {
                      try {
                              img = ImageIO.read(Kitten);
                          } 
                      catch (IOException e1)
                          {
                              e1.printStackTrace();
                          }
                  }
  
          }
          public static void main(String[] args)
          {
             createGUI();
            }
              private static void createGUI() {
  
  
                  JFrame frame = new JFrame("Kitten Changer");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  KittenChanger newContentPane = new KittenChanger();
                  newContentPane.setOpaque(true);
                  frame.setContentPane(newContentPane);
                  frame.setSize(400, 500);
                  frame.setLocationRelativeTo(null);
                  frame.setVisible(true);
              }
  
  //Grayscale and rgb filter methods follow, not important to question
  }
  </code></pre>
  
  <p>How would I create a method for this sort of filter and properly apply it to a button like the others?</p>