Re: Looping through an Array
Your a array is an array of Color objects, and for a Color object a click is meaningless. What does it mean for instance to call Color.RED.click(myClickX, myClckY)? It doesn't make either logical sense or code sense. Instead you need to associate clicks with visualized *components* that are clicked, that have the MouseListener attached to them.
If this were my application, I'd simplify things quite a bit, would be sure to use the Swing library, meaning using a JApplet, have my applet hold a JPanel that used a GridLayout and that held an array of JLabels. I'd make my JLabels opaque so that they showed their background Color, and would add a MouseListener to the JLabels in a for loop.
Edit: you've already been told about using a JPanel and have been given good suggestions in your previous post that you didn't mention in this one. I suggest that you either follow my advice or camicker as either would solve this problem. I also suggest that you let us know if you already have an active similar question when asking questions so we can see in advance what has been discussed before.