Reputation: 95
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?
Upvotes: 1
Views: 682
Reputation: 52770
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.
Upvotes: 2
Reputation: 19347
What about deriving the Label
class and implementing the paint(Graphics g)
method ! There you can use the Graphics
object 'g' to draw
the line
and the image
.
Upvotes: 1