I agree that your example works great and accomplishes the goal. The problem the OP has is with the process of updating values of variables between classes, and using inner classes that all refer to...
Type: Posts; User: KevinWorkman
I agree that your example works great and accomplishes the goal. The problem the OP has is with the process of updating values of variables between classes, and using inner classes that all refer to...
The above example sorta "cheats" by throwing it all in a single class and using inner classes. I think the OP is going for a solution using multiple classes. I'm not going to spoonfeed him the...
You don't pass a Shape value into the MyControlPanel constructor, do you? And you call a setShape() function on the MyControlPanel class, right? So why not do something similar with your DrawShape...
You already set the shape value in MyControlPanel, why can't you do something similar with the DrawShape class?
You need to set the value of theShape in DrawShape whenever the user changes it. Java doesn't automagically update variables for you. For example:
String s = "one";
String t = s;
s = "two";...
I see that you're setting the value of theShape in your MyControlPanel class, but that's a completely different variable than theShape in your DrawShape class.
Your DrawShape instance is inside your MyControlPanel constructor. How are any of the listeners accessing that instance to pass in the selected shape or size?
Again, I highly suggest taking this...
When do you add the DrawShape to the JFrame? When do you call the setShape() method?
I recommend hardcoding a shape and putting it in a basic JFrame by itself and seeing if that works. Test your...
What does your posted code do? What do you expect it to do? This would all be so much easier to help you with if you started with an SSCCE instead of chunks of your whole program.
One thing that...