title: What is wrong with my applet code?
body: <p>I am following a tutorial on applets on Youtube.  My code looks exactly the same as the tutorial's does, but the background does not turn pink and Eclipse tells me there are errors in <code>implements MouseListener</code> and <code>g2.draw(line);</code>  What did I do wrong?  <a href="https://www.youtube.com/watch?v=dVfZ0P6AAn8" rel="nofollow">Click here</a> for the video and here is my code:</p>
  
  <pre><code>package applets1;
  
  import java.awt.Color;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.geom.Line2D;
  import java.awt.geom.Point2D;
  
  import javax.swing.JApplet;
  
  public class clean extends JApplet implements MouseListener{
  
  public void start(){
  
  
  
  }
  
  public void init(){
  
      setBackground(Color.pink);
      addMouseListener(this);
  
  }
  
  public void paint(Graphics g){
  
      Graphics g2D = (Graphics2D) g;
  
      g.drawString("WAZZUP", 100, 90);
      g.drawRect(100, 100, 400, 400);
  
      Point2D.Double topLeft = new Point2D.Double(0.0, 25.0);
      Point2D.Double topRight = new Point2D.Double(100.0, 25.0);
  
      Line2D.Double line = new Line2D.Double(topLeft, topRight);
  
      g2D.draw(line);
  
  }
  }
  </code></pre>
  
  <p>EDIT: The error at <code>g2D.draw(line);</code> says <code>The method draw(Line2D.Double) is undefined for the type Graphics</code>.  I changed <code>g2D.drawLine</code> to <code>g2D.draw</code>
  I also fixed the <code>implements</code> typo.  The background is still not pink, despite the absence of an error and everything else works.  What can I do to fix the pinkness and <code>g2D.draw</code>?</p>