@Override public Dimension getPreferredSize() { if (img == null) { return new Dimension(100, 100); } else { return new Dimension(img.getWidth(), img.getHeight()); } }
@Override public void paint(Graphics g) { g.drawImage(img.getImage(), 0, 0, null); }
public ImagePanel(String imagePath) { img = Image.loadImage(imagePath); }