Can someone take a look at my code and see why my SetShape method is not taking in/reading my shapes. It's not taking in Circle, Rectangle, or Triangle, and I have no clue why. Thanks. What I mean is on line 72, aShape.equals(Circle); does not recognize Circle even though Circle passes through all previous methods above.
import java.awt.*;
2 import java.awt.event.MouseEvent;
3 import java.awt.event.MouseListener;
4 import java.awt.Color;
5 import javax.swing.*;
6
7 public class CoolDrawPanel extends JPanel
8 {
9 //declare variables to use
10 private int x = 0, y = 0; //trackers
11 public static Shape aShape; //instance of a new shape
12 public static Color aColor = Color.green; //instance of a new color
13 public static Shape Rectangle = null, Triangle= null, Circle = null; //create the shapes Rectangle, Triangle, Circle
14
15 public CoolDrawPanel()
16 {
17 //add mouse listener
18 addMouseListener (new CoordinatesListener());
19
20 //create an instance of the shapes
21 Circle = new CircleShape();
22 Rectangle = new RectangleShape();
23 Triangle = new TriangleShape();
24
25 //set the window dimensions to 500, 500
26 setPreferredSize (new Dimension(500, 500));
27
28 //set the background color to white
29 setBackground (Color.white);
30 }
31
32 //create methods to draw the selected shape on the panel
33 public void paintComponent (Graphics g, Point q)
34 {
35 g.setColor (aColor); //sets the shape to the current color
36 aShape.draw (aColor, g, q); //takes the shape, and sets the color at point q
37 }
38
39 //create the mouse listener events
40 private class CoordinatesListener implements MouseListener
41 {
42 //provides the definition for unused mouse events, must be declared
43 public void mouseEntered(MouseEvent event)
44 {}
45 public void mouseExited(MouseEvent event)
46 {}
47 public void mouseClicked(MouseEvent event)
48 {}
49 public void mouseReleased(MouseEvent event)
50 {}
51
52 //adds the current point to the list of points and redraws the shape whenever the mouse event occurs
53 public void mousePressed (MouseEvent event)
54 {
55 x = event.getX();
56 y = event.getY();
57 repaint(); //repaints whenever the menu bar is used, if there are already shapes in the panel
58 }
59 }
60
61 //instantiates the color that the user chooses to the shape
62 public static void setColor (Color color)
63 {
64 aColor = color;
65 }
66
67 //instantiates the shape that the user chooses to the panel
68 public static void SetShape (String shape)
69 {
70 if (shape.equalsIgnoreCase("Circle"))
71 {
72 aShape.equals(Circle);
73 }
74 if (shape.equalsIgnoreCase("Rectangle"))
75 {
76
77 aShape.equals(Rectangle);
78 }
79 if (shape.equalsIgnoreCase("Triangle"))
80 {
81 aShape.equals(Triangle);
82 }
83 }
84 }