title: Error loading image to set background
body: <p>I am trying to load an image and set to background, but i get the error at selectionPanel method "Could not load background image".</p>
  
  <p>It seems that something is going wrong with the image processing but i cant find out what.</p>
  
  <pre><code>public class selectionPanel extends JPanel
  {
    //Variable with the name of our pic
    private static final String path = "selbkgrnd.jpg";
    private ImageIcon imageIcon;
    private Dimension windowSize;
    private int imageHeight;
    private int imageWidth;
  
    protected selectionPanel()
    {
  
      this.imageIcon = new ImageIcon("selbkgrnd.jpg"); //Save image to imageIcon
      Image image = this.imageIcon.getImage();
      this.imageWidth = image.getWidth(null);
      this.imageHeight = image.getHeight(null);
      if ((this.imageWidth == -1) || (this.imageHeight == -1)) //Check if background image is succesfully loaded
      {
        JOptionPane.showMessageDialog(JOptionPane.getDesktopPaneForComponent(this), "Could not load background image", "Fatal error!", 0);
  
        System.exit(-1);
      }
      this.windowSize = new Dimension(this.imageWidth, this.imageHeight);
    }
  
    protected void startScreen()
    {
      setOpaque(false);
      setSize(this.windowSize);
    }
  
    protected int getImageHeight()
    {
      return imageHeight;
    }
  
    protected int getImageWidth()
    {
      return imageWidth;
    }
  
    @Override
    public void paintComponent(Graphics g)
    {
      g.drawImage(this.imageIcon.getImage(), 0, 0, null);
      super.paintComponent(g);
    }
  }
  </code></pre>