title: Why won't my JFrame program change background color?
body: <p>This is a program that goes full screen for five seconds then go back to normal. What i am trying to do is change the back ground color to yellow. I tried getContentPane().setBackground(Color.YELLOW) but it still does not work.</p>
  
  <pre><code>  package gamedev;
  
     import java.awt.Color;
     import java.awt.DisplayMode;
     import java.awt.Font;
     import java.awt.Graphics;      
     import java.io.PrintWriter;
     import javax.swing.JFrame;
  
    public class GameDev extends JFrame {
  
     public static void main(String[] arg) {
  
      DisplayMode dm = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
      GameDev b = new GameDev();
      b.getContentPane().setBackground(Color.yellow);
      b.run(dm);
  
  }
  
  public void run(DisplayMode dm) {
      setBackground(Color.YELLOW);
      setForeground(Color.red);
      setFont(new Font("Arial", Font.PLAIN, 25));
  
      Screen s = new Screen();
      try {
          s.setFullScreen(dm, this);
          try {
              Thread.sleep(5000);
          } catch (Exception ex) {
          }
  
      } finally {
          s.restoreScreen();
      }
  }
  
  public void paint(Graphics g) {
  
      g.drawString("You know you love me home boy.", 200, 200);
  
  }
  }
  </code></pre>
  
  <p>and second class</p>
  
  <pre><code>   package gamedev;
  
     import java.awt.DisplayMode;
     import java.awt.GraphicsDevice;
     import java.awt.GraphicsEnvironment;
     import java.awt.Window;
     import javax.swing.JFrame;
  
     public class Screen {
  
      GraphicsDevice videoCard;
  
      public Screen() {
  
         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
        videoCard = env.getDefaultScreenDevice(); // acces computer screen
  
     }
  
      public void setFullScreen(DisplayMode dm, JFrame window) { 
      window.setUndecorated(true);
      window.setResizable(false);
      videoCard.setFullScreenWindow(window);
  
      if (dm != null &amp;&amp; videoCard.isDisplayChangeSupported()) {
  
          try {
  
              videoCard.setDisplayMode(dm);
  
          } catch (Exception ex) {
  
          }
        }
     }
  
    public Window getFullScreenWindow() {
  
      return videoCard.getFullScreenWindow(); //returns ur window
  
    }
  
  public void restoreScreen() {
  
      Window w = videoCard.getFullScreenWindow();
  
      if (w != null) {
  
          w.dispose();
      }
      videoCard.setFullScreenWindow(null); // takes away from full screen.
     }
  }
  </code></pre>