title: java swing component cannot be resolved
body: <p>I took the following code from a tutorial:</p>
  
  <pre><code>import javax.swing.*;
  import java.util.Date;
  
  public class SwingGUI {
  
      public static void main( String[] args )
        {
          JFrame f = new JFrame( "test" );
          f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          f.setSize( 1500, 900 );
          JLabel l = new JLabel( String.format( "%tT", new Date() ) );
          f.add(l);
          f.setVisible( true );
        }
  }
  </code></pre>
  
  <p>The <code>f.add(l);</code> is highlighted and two errors are shown:</p>
  
  <ul>
  <li><p>The method add(Component) in the type Container is not applicable for the arguments (JLabel)</p></li>
  <li><p>The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from required .class files</p></li>
  </ul>
  
  <p>Being relatively new to java, I do not really understand what Eclipse is trying to tell me. What can I do to make it work?</p>
  
  <p>edit: The code runs without the line <code>f.add(l);</code>, so the problem is not that JFrame or JLabel are not found. After fiddeling around a little I got rid of the first error, but the second still remains. The component cannot be resolved, because it is indirectly referenced. What does that mean?</p>