I have a VerticalFieldManager that renders a white round rectangle.
This is the code:
VerticalFieldManager _vfmBackground = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL |
Manager.NO_VERTICAL_SCROLLBAR | Manager.USE_ALL_WIDTH){
public void paint(Graphics graphics)
{
graphics.clear();
graphics.setColor(Color.WHITE);
graphics.fillRoundRect(10, 10,460, 400, 25,25 );
super.paint(graphics);
}
protected void sublayout(int maxWidth, int maxHeight)
{
int displayWidth = (Display.getWidth());
int displayHeight = (Display.getHeight());
super.sublayout( displayWidth, displayHeight);
setExtent( displayWidth, displayHeight);
}
};
Then I create a custom Manager class named BaseHeaderBlueScreen that renders a blue rectangle:
public void paint(Graphics graphics)
{
graphics.clear();
graphics.setColor(610212);
graphics.fillRect(20, 0, Display.getWidth(), Display.getHeight());
super.paint(graphics);
}
protected void sublayout(int maxWidth, int maxHeight)
{
int displayWidth = (Display.getWidth()-40);
int displayHeight = ((Display.getHeight()/2))-90;
super.setExtent( displayWidth, displayHeight);
}
Finally, I add that custom manager to the VerticalFieldManager with the white rounded rectangle:
BaseHeaderBlueScreen _vhbs = new BaseHeaderBlueScreen(textTop, textBottom, 0);
_vhbs.setPadding(20,30,0,0);
_vfmBackground.add(_vhbs);
This is how the blue rectangle should be displayed within the white rectangle.

But this is how the blue rectangle is currently being displayed (please note the gray space of its left side):

How should I do to render the blue rectangle exactly as desired (without the left gray border)?
I think you’re just unnecessarily making a call to
Graphics.clear().clear()is meant to fill in the graphics area with whatever color is currently set as the background color. Normally, you would useclear()like this:From the API docs for clear():
But, you’re calling
clear()before you make any other calls.So, just remove the two calls to
clear()(although the one that’s causing this particular problem is the call inBaseHeaderBlueScreen.paint()).