imagePanel = new ImagePanel();
Dimension size = new Dimension(400, 300);
File file = (args.length > 0) ? new File(args[0]) : null;
if (file != null) {
try {
PngImage png = readHeader(file);
size.setSize(png.getWidth(), png.getHeight());
} catch (IOException e) {
// ignore here, open will re-throw
}
}
imagePanel.setStretchMode(ImagePanel.STRETCH_PRESERVE);