Stephan van Hulst wrote:Two questions. Why are you using a random index, and why are you checking for listeners in the first place?
Carey Brown wrote:This seems overly complex. Can you describe in English what your overall requirements are?
Stephan van Hulst wrote:Because some people find that bad practice. Don't ask me why. I think it's silly and usually disable this warning in my IDE.
In your particular case it kind of makes sense though. Why does your method take a buttonArray parameter when you're going to overwrite the passed value immediately? Java is pass-by-value and method parameters can't be used to change the variable in the calling code.
Another thing that doesn't make sense is that your method is called setArrayLists, but it doesn't set anything and it doesn't work with ArrayLists.
Piet Souris wrote:
In your code, you have two Main objects, with ditto buttons. One Main is set in the main method of Main itself, the second Main is created in the setActionListener() method of te class ChangeButton. It is that second button that has its color changed, but the first button, as shown in the frame, is left unchanged. Therefore you see nothing happening with that button.