BlackBerry Field class extension will not paint.
Posted
by jlindenbaum
on Stack Overflow
See other posts from Stack Overflow
or by jlindenbaum
Published on 2010-05-12T22:42:26Z
Indexed on
2010/05/12
22:44 UTC
Read the original article
Hit count: 131
blackberry
|java
Using JRE 5.0.0, simulator device is an 8520.
On a screen I am using a FlowFieldManager(Manager.VERTICAL_SCROLL) and adding Fields to it to show data.
When I do
this.flowManager = new FlowFieldManager(Manager.VERTICAL_SCROLL);
Field field = new Field()
{
protected void paint(Graphics graphics)
{
graphics.drawTest("Test", 0, 0);
}
protected void layout(int width, int height)
{
this.setExtend(300, 300); // just testing
}
}
this.flowManager.add(field);
The screen renders correctly and 'Test' appears on the screen.
If, on the other hand, I try and abstract this into a class called CustomField with the same properties and add it to the flow manager the render will not happen. Debugging shows that the device enters into the Object, into the layout function, but not the paint function.
I can't figure out why the paint function is not called when I extend Field. The 4.5 API says that layout and paint are the only functions that I really need to extend. (getPreferredWidth and getPreferredHeight will be used to calculate screen sizes etc.)
Thanks in advance.
© Stack Overflow or respective owner