What is the simplest way to read and display a jpeg image in Java?
Printable View
What is the simplest way to read and display a jpeg image in Java?
There are a lot better ways to read and display images, but start with something that works and look through the java.awt. and javax.swing classes for ways to improve it.Code:import javax.swing.JFrame ;
class JpgMini {
public static void main(String [] args) {
JFrame f = new JFrame(args[0]);
f.getContentPane().add(new javax.swing.JLabel(new javax.swing.ImageIcon(args[0])));
f.setSize(200,200);
f.setVisible(true);
}
}