문제

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.

도움이 되었습니까?

해결책

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);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top