BlackBerry: Overriding paint() vs subpaint()

前端 未结 1 910
盖世英雄少女心
盖世英雄少女心 2021-01-28 05:39

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

相关标签:
1条回答
  • 2021-01-28 05:53

    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.

    0 讨论(0)
提交回复
热议问题