title: Java Applet: setForeground() what exactly it does? and how to see it's effect?
body: <p>As per "Java - The Complete Reference Java" <code>setForeground()</code> is used to set the foreground colour i.e the colour in which text is shown.</p>
  
  <p>Now consider this basic applet program that sets the foreground and background colours and outputs a string:</p>
  
  <pre><code>import java.awt.*;
  import java.applet.*;
  
  /*
  &lt; applet code="Sample" width=1000 height=500&gt;
  &lt; /applet&gt;
  */
  
  public class Sample extends Applet
  {
      String msg;
      // set the foreground and background colors.
  
      public void init() 
      {
          setBackground(Color.white);
          setForeground(Color.red);
          msg = "Inside init( ) --";
      }
  
      // Initialize the string to be displayed.
      public void start()
      {
          msg += " Inside start( ) --";
      }
  
      // Display msg in applet window.
      public void paint(Graphics g)
      {
        msg += " Inside paint( ).";
        g.drawString(msg, 10, 30);
      }
  }
  </code></pre>
  
  <p><code>The background colour can be changed to any colour by setBackground()</code> BUT <strong>no matter what colour given inside setForegorund() the text is always black!!!</strong> i.e it does not change the text colour at all. Then what is the function/use of <code>setForegorund()</code> , and how can I see the effect of it?</p>
  
  <p>Thank you</p>