I need to replace a Swing application in wich I used an image (dinamycally loaded) and, on that image the user can click and the system will keep the position of the click in resect to the image root position (x and y of the click).
Once clicked in the clicked point I need to show a small “red point” (I’ve another image for that).
Is there any component suitable for such operation ?
Any suggestion ?
Tks
Hi.
I think you could get the functionality implemented with AbsoluteLayout that has the base image in position 0,0
AbsoluteLayout layout = new AbsoluteLayout();
layout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
@Override
public void layoutClick(LayoutEvents.LayoutClickEvent event) {
int clickX = event.getRelativeX();
int clickY = event.getRelativeY();
layout.addComponent(pointImageComponent, "top:" + clickY + "px; left:" + clickX + ";");
}
});
Just use the RelativeX and RelativeY for the clickEvent to position the point image into the absolute layout.