Пример #1
0
 @Override
 public Dimension getPreferredSize() {
   if (img == null) {
     return new Dimension(100, 100);
   } else {
     return new Dimension(img.getWidth(), img.getHeight());
   }
 }
Пример #2
0
 @Override
 public void paint(Graphics g) {
   g.drawImage(img.getImage(), 0, 0, null);
 }
Пример #3
0
 public ImagePanel(String imagePath) {
   img = Image.loadImage(imagePath);
 }