Win a copy of Raising Young Coders: A Parent’s Guide to Teaching Programming at Home this week in the General Computing forum!
Forums Login/signup

accessing Canvas paint() method from another class? (SOLVED)

+Pie Number of slices to send: Send
Hello,
I have the following (simplified example code):

This works so far.
Now I'd like to access above paint() method also in another (utility) class, to draw various things on screen, is this possible?

edit:
I have it working, I think:

Is this the corect (only) way to do it?
What concerns me a bit is that all public / proteced members members are now also in this class, but I actually don't need it there, I only want to access the paint() method from the other class..

edit2:
Solved.
I figured the simplest way is to pass g in the method calls, than I can acces it directly in my utility class.



reply
reply
This thread has been viewed 676 times.
Similar Threads
North Panel Not Displaying....
Adding a shape to a canvas
hi please help with conversion from awt to swing
Canvas
basic doubt in program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Jun 27, 2025 09:01:48.