Load image to ImageIcon and add it to Panel : ImageIcon « 2D Graphics « Java Tutorial






import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class MainClass extends JFrame {
  public static void main(String[] args) {
    new MainClass();
  }

  public MainClass() {
    this.setTitle("Picture Application");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel1 = new JPanel();
    ImageIcon pic = new ImageIcon("your.jpg");
    panel1.add(new JLabel(pic));
    this.add(panel1);
    this.pack();
    this.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