GWT Graphics - resetting the text
Question
I am working on a project for which i am using GWT-Graphics. I have drawing Area containing ellipse and text. When i double click on them a pop-up menu appears and gives an option to enter text. Now when i save this text i want it to appear on this drawing area in the place of the previous text.
I am trying to do this but with no luck. It keeps the old text and on top of that it includes the current text. Is there a way to have only the new text to appear.
Any input will be of great help. Thank you.
Solution
For me this sounds like that you are adding a new Text element instead of using the existing one. I wrote a quick test and it seems to work like you want:
public class GwtTest2 implements EntryPoint {
private Text text;
public void onModuleLoad() {
DrawingArea da = new DrawingArea(400, 400);
RootPanel.get().add(da);
da.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String newTextValue = Window.prompt("", "");
text.setText(newTextValue);
}
});
Ellipse ellipse = new Ellipse(200, 200, 100, 50);
da.add(ellipse);
text = new Text(150, 200, "Hello world!");
da.add(text);
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow