I have the code below and I am trying to catch an exception and print out something if the file == null so it doesn't throw an exception but I am having problems solving this.
public class Controller {
private ImageWindow IW = new ImageWindow(this);
private Model M = new Model(this.IW);
private File file = null;
public void openImage() {
File file = IW.ChooseImageFile();
if (file != null) {
M.loadImage(file);
}
this.IW.setVisible(true);
}
public static void main(String[] args) throws IOException {
SwingUtilities.invokeLater(() -> new Controller());
}
}