title: Java: Why are my JButtons being painted behind the background image?
body: <p>Here is the JPanel class that is having the issue:</p>
  
  <pre><code>public class EntryDialog extends JPanel{
  
  private static final long serialVersionUID = 1L;
  
  MainWindow         mainWindow;
  Image              background;
  JButton            continueresume;
  JButton            newresume;
  JButton            settings;
  JButton            exit;
  
  public EntryDialog(MainWindow mainWindow){
  
      continueresume            = new JButton("Continue resume");
      newresume                 = new JButton("New resume");
      settings                  = new JButton("Settings");
      exit                      = new JButton("Exit");
      this.mainWindow           = mainWindow;
      this.background           = Utilities.getImage("images\\entryDialogBackground.jpg", true);
  
      this.setLayout(null);
  
      //continueresume button
      continueresume.setBounds(Utilities.getScaledWidth(1150), 
              Utilities.getScaledHeight(150), 
              Utilities.getScaledWidth(500), 
              Utilities.getScaledHeight(50));
  
      //newresume button
      newresume.setBounds(Utilities.getScaledWidth(1150), 
              Utilities.getScaledHeight(220), 
              Utilities.getScaledWidth(500), 
              Utilities.getScaledHeight(50));
  
      //settings button
      settings.setBounds(Utilities.getScaledWidth(1150), 
              Utilities.getScaledHeight(290), 
              Utilities.getScaledWidth(500), 
              Utilities.getScaledHeight(50));
      //exit button
      exit.setBounds(Utilities.getScaledWidth(1150), 
              Utilities.getScaledHeight(360), 
              Utilities.getScaledWidth(500), 
              Utilities.getScaledHeight(50));
  
      this.add(continueresume);
      this.add(newresume);
      this.add(settings);
      this.add(exit);
  
  }
  
  @Override
  public void paintComponent(Graphics g){
      super.paintComponent(g);
      Graphics2D g2d = (Graphics2D) g;
      if(background != null){
          g2d.drawImage(background, 0, 0, this);
      }
      g2d.dispose();
  }
  </code></pre>
  
  <p>This JPanel is being painted to a main frame in another class. What is happening is "background" is being painted just fine, but the buttons are not. The buttons appear once I hover over them with my mouse but until then they are invisible. I have searched for hours and not come to a solution so any help would be appreciated. Thanks!</p>