When making a custom field, what should I consider between overriding the paint()
vs subpaint()
methods to render custom parts of a field?
My c
subpaint()
is really used for Managers, not necessarily a custom Field (yeah, Manager is a Field). It's default implementation is to just loop through its child Fields and issue a paintChild()
call on it. paint()
, on the other hand, is for the Field to do drawing related to itself. In your case, you should be overriding paint()
.
So why would you override subpaint()
? You would want to if you need child Fields to paint themselves in a certain order. Say that you have a custom Manager that places some Fields on top of each other. If they need to be painted in a certain order, you would override subpaint()
to make sure the right Field is "on top." Also, a Manager's paint()
will call its subpaint()
, something to keep in mind if you override it.