Change JFrame image icon : ImageIcon « 2D Graphics « Java Tutorial






import java.awt.Dimension;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class Main extends JFrame {
  public static void main(String[] args) throws Exception {
    Main frame = new Main();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(new Dimension(300, 200));
    BufferedImage image = ImageIO.read(frame.getClass().getResource("/colors.jpg"));
    frame.setIconImage(image);
    frame.setVisible(true);
  }
}








16.32.ImageIcon
16.32.1.Load image to ImageIcon and add it to Panel
16.32.2.Load an Icon from a jar
16.32.3.Convert a non-RGB image to an RGB buffered image:
16.32.4.Return a filled oval as an Icon
16.32.5.Change JFrame image icon
16.32.6.A button which paints on it one or more scaled arrows in one of the cardinal directions
16.32.7.RGB Gray Filter