I’m making a BlackBerry OS 6+ application and I need to draw a solid square of a specific color (given at runtime) but it should be add-able to a VerticalFieldManager. So I think custom-drawing using a Graphics object is not an option.
I already tried setting the background color of a LabelField to the color I want and adding that LabelField to the VerticalFieldManager. To get the square-shaped appearance, I tried overriding the getPreferredWidth() and getPreferredHeight of LabelField to return a higher value (eg: 150). But although the width was correctly displayed, the height stayed the same no matter what value I returned.
So is there any way I can achieve this? In summary, what I want is:
- A solid square-shaped block of color (color decided at runtime).
- Which should be added to a
VerticalFieldManager.
Thanks in advance!
try this code , Pass in the color in the constructor.