try { currentTile.setImage(ImageIO.read(ch.getSelectedFile())); } catch (Exception e) { e.printStackTrace();
if (ret == JFileChooser.APPROVE_OPTION) { File file = ch.getSelectedFile(); try { BufferedImage image = ImageIO.read(file); if (image != null) { currentTile.setImage(image); } else { JOptionPane.showMessageDialog(this, "Error loading image", "Error loading image", JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, e.getMessage(), "Error loading image", JOptionPane.ERROR_MESSAGE); }
    private void changeImage() {        JFileChooser ch = new JFileChooser();        ch.setMultiSelectionEnabled(true);        int ret = ch.showOpenDialog(this);        try {            currentTile.setImage(ImageIO.read(ch.getSelectedFile()));        } catch (Exception e) {            e.printStackTrace();        }    }