I have an image label created like this.
Painter painter = new Painter()
{
public void paint(Graphics g, Rectangle rctngl)
{
g.setColor(0x000000);
g.drawLine(0, 0, 100, 100);
}
};
mapScreen = new Form("Map");
try
{
Image image = Image.createImage("/res/Sample.jpg");
Label labelImage = new Label(image);
labelImage.setScrollVisible(true);
labelImage.setFocus(true);
labelImage.getStyle().setBgPainter(painter);
mapScreen.addComponent(labelImage);
I want to draw some lines on top of it. I have tried using painter like the code above but I was not able to do it successfully. How am I doing wrong and how can I fix it?
EDIT:
The drawing of the lines is successful but the problem is that the lines are drawn behind the labelImage. How can I make it so that the lines will be drawn infront?
You need to apply the painter to Unselected and Selected style since you give the label focus. You are also drawing a diagonal line not a strait line.