Vuoi un semplice visualizzatore di immagine? (chiaramente altamente migliorabile ... è solo un esempio)
codice:
import javax.swing.*;
public class ImageViewerFrame extends JFrame
{
private JScrollPane scrollPane;
private JLabel imageLabel;
public ImageViewerFrame (ImageIcon icon)
{
super ("Image Viewer");
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setSize (300, 300);
imageLabel = new JLabel (icon);
scrollPane = new JScrollPane (imageLabel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add (scrollPane);
}
public static void main (String[] args)
{
if (args.length == 1)
{
final ImageIcon icon = new ImageIcon (args[0]);
SwingUtilities.invokeLater (new Runnable ()
{
public void run ()
{
ImageViewerFrame f = new ImageViewerFrame (icon);
f.setVisible (true);
}
});
}
}
}