posted 15 years ago
I was hoping to wait for someone with more experience to comment mainly because of your static keyword before the Circle class. Also I'm self taught and by no means a java expert. However I can "make" things work. So as my intentions might be pure my programming might not and I was hoping not to pass on any bad habits but here's how I'd make a quick fix. First I want to explain why it can't access the m1 variable. There is no reference to it. The class a() has no idea where m1 is coming from because it has not been declared. Because the Circle class is static I suspect, but have not tested, that if you do call the Circle class and change m1 you will change it or all Circles however you will be unable to repaint the one residing in your JFrame so you need to point to the Circle that your displaying in your JFrame. Currently your code Circle circ is Empty/Null so you will have to call new Circle() before you can reference the object circ. Then you need to make a parameter for myButtonListener(Circle) so that you can pass that exact Circle to the class and alter it's attributes. After that it compiles and works fine for me.