title: How to put an image in the background of a window
body: <p>I'm almost done with my hangman java code. I want to add a picture in the background though.(nightsky.png) How do I do this in the paint graphics method? I created a imageicon in the beginning.</p>
  
  <pre><code>public HangmanRevised() {
      setSize(600,400);
      setLocationRelativeTo(null);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLayout(new FlowLayout());
  
      ImageIcon background = new ImageIcon("nightsky.png");
      Letter = new TextField();
      JLabel label = new JLabel("pick a Letter");
      button = new Button("Enter");
      add(label);
      add(button);
      add(Letter);
  
      button.addActionListener(this);
  
      createGame(); 
  } 
  
  public void paint(Graphics g) {
      super.paint(g);
      g.drawImage(background, 0, 156, Color.green, button);
  }
  </code></pre>