Studyon Minte9.com
Java SE




Image




package testexample; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import javax.swing.*; public class Test extends JFrame { public static void main(String[] args) { Test frame = new Test(); frame.setBounds(200, 200, 300, 300); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setLayout(new FlowLayout()); // not BorderLayout ! frame.setVisible(true); } public Test() { // --- Look Here --- // try { String imageFile = "data/images/red.png"; BufferedImage image = ImageIO.read(new File(imageFile)); JLabel imageLabel = new JLabel(new ImageIcon(image)); add(imageLabel); } catch (Exception e) {} } }