GWT Graphics - 重置文本

发布于 2024-08-23 04:52:13 字数 406 浏览 4 评论 0原文

我正在开发一个正在使用的项目 GWT-Graphics。我有包含椭圆和文本的绘图区域。当我双击它们时,会出现一个弹出菜单,并提供输入文本的选项。现在,当我保存此文本时,我希望它出现在该绘图区域上之前文本的位置。

我正在尝试这样做,但没有运气。它保留旧文本,并在其之上包含当前文本。有没有办法只显示新文本。

任何输入都会有很大帮助。 谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城°AllureLove 2024-08-30 04:52:13

对我来说,这听起来像是您正在添加一个新的 Text 元素,而不是使用现有的元素。我写了一个快速测试,它似乎按您想要的方式工作:

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);
    }
}

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);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文