0
我正在尝试创建自定义Label
。我想根据用户输入的内容,在Image
上做标记。我真的不知道该怎么做,但我希望你能知道我在这里想达到的目标。什么是派生类Label
的正确方法?这是我的代码。LWUIT标签:创建自定义标签
class CustomLabel extends Label
{
List paths;
Image image;
public CustomLabel(Image img,List paths)
{
this.image = img;
this.paths = paths;
}
public void paint(Graphics g)
{
g.setColor(0x000000);
for (int i = 0; i < paths.size(); i++)
{
Path path = (Path)paths.getModel().getItemAt(i);
int firstLocX = path.discoveredNode.getX();
int firstLocY = path.discoveredNode.getY();
int secondLocX = path.nodeDiscovered.getX();
int secondLocY = path.nodeDiscovered.getY();
g.drawLine(firstLocX, firstLocY, secondLocX, secondLocY);
}
g.drawImage(image, 0, 0);
UIManager.getInstance().getLookAndFeel().drawLabel(g, this);
}
}
我希望你能帮助我。
感谢,