title: Why won't my background color display in JFrame?
body: <p>I have two class files:</p>
  
  <p>Screen <a href="https://gist.github.com/3020101" rel="nofollow">https://gist.github.com/3020101</a></p>
  
  <p>JMain <a href="https://gist.github.com/3020107" rel="nofollow">https://gist.github.com/3020107</a></p>
  
  <p>I'm trying to get it to go fullscreen for 5 seconds and display the background (or, at this point, even the foreground) but when I run it it goes fullscreen for 5 seconds, yay, but it is just a blank light grey screen.</p>
  
  <p>What am I doing wrong? Eventually I'm going to use an image for the background and I want to make sure I'm not screwing up somewhere.</p>
  
  <p>Thanks guys!</p>
  
  <p>Edit: When I add this at the end of my JMain class the font color is the same as the foreground color, but the background is always black no matter what color I change it to in the program.</p>
  
  <pre><code>public void paint(Graphics g) {
      g.drawString("This is gonna be awesome", 200, 200);
  }
  </code></pre>
  
  <p>code from github</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.JFrame;
  
  public class JMain extends JFrame {
  
      private JFrame frame = new JFrame();
  
      public static void main(String[] args) {
          DisplayMode dm = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
          JMain m = new JMain();
          m.run(dm);
      }
  
      public void run(DisplayMode dm) {
          this.getContentPane().setBackground(Color.RED);
          frame.setForeground(Color.BLACK);
          frame.setFont(new Font("Arial", Font.PLAIN, 24));
          Screen s = new Screen();
          try {
              s.setFullScreen(dm, this);
              try {
                  Thread.sleep(5000);
              } catch (Exception ex) {
              }
          } finally {
              s.restoreScreen();
          }
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>import java.awt.*;
  import javax.swing.JFrame;
  
  public class Screen {
  
      private GraphicsDevice vc;
  
      public Screen() {
          GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
          vc = env.getDefaultScreenDevice();
      }
  
      public void setFullScreen(DisplayMode dm, JFrame window) {
          window.setUndecorated(true);
          window.setResizable(false);
          vc.setFullScreenWindow(window);
          if (dm != null &amp;&amp; vc.isDisplayChangeSupported()) {
              try {
                  vc.setDisplayMode(dm);
              } catch (Exception ex) {
              }
          }
      }
  
      public Window getFullScreenWindow() {
          return vc.getFullScreenWindow();
      }
  
      public void restoreScreen() {
          Window w = vc.getFullScreenWindow();
          if (w != null) {
              w.dispose();
          }
          vc.setFullScreenWindow(null);
      }
  }
  </code></pre>