Java tutorial
import java.awt.BorderLayout; import java.io.File; import javax.swing.Icon; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; public class Main { public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File file = new File("filename.txt"); Icon icon = chooser.getIcon(file); JLabel label = new JLabel("" + file); label.setIcon(icon); JFrame frame = new JFrame(); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } }