This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Classes" Watch "Classes" New topic


Janner Aglith

Joined: Jul 02, 2012
Posts: 1
In the paintComponent() in the Circle Class, I have the Circle accessing the super classes variables through methods, is there a better way to do this?

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43975
You are correct the way you are handling the return values. A Shape has location and colour. I am not convinced that a circle has radius and diameter; I would remove the diameter field and change the getDiameter method, if I need it at all:-The paintComponent method ought not to be part of the Shape class. It is part of the Component class, and should not be in other classes. It should also have protected access. How do you paint the shapes then? Start with this thread, which will probably answer that question.

And welcome to the Ranch
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Classes
It's not a secret anymore!