title: How To Change Applet Color
body: <p>I need some help with this program I have to create for Uni. The problem is that the setColor and getColor methods do no work, and the line doesn't change color when I want it too. </p>
  
  <p>What do I need to do to change the color of the line to red?</p>
  
  <p>Cheers</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Point;
  import javax.swing.JPanel;
  import java.awt.*;
  
  public class Shape extends JPanel {
  static Point startPoint = new Point(0, 0);
  Point controlPoint = new Point(0, 0);
  
  Color colour = Color.BLACK;
  
  public Shape() {
      this(startPoint);
  
  }
  
  public Shape(Point startPoint) {
      // initialise variable startPoint
      this.startPoint = startPoint;
      // execute methods setColour and setControlPoint
      setColor(colour);
      setControlPoint(controlPoint);
      // change startPoint
      startPoint.x = 50;
      startPoint.y = 50;
  
  }
  
  public void setColor(Color colour) {
      this.colour = colour;
      colour = Color.RED;
  }
  
  public Color getColor() {
      return colour;
  }
  
  public void setControlPoint(Point controlPoint) {
      controlPoint.x = 150;
      controlPoint.y = 150;
  }
  
  public void paintComponent(Graphics g) {
      super.paintComponents(g);
      g.setColor(colour);
      g.drawLine(startPoint.x, startPoint.y, controlPoint.x, controlPoint.y);
  }
  </code></pre>
  
  <p>}</p>