gpt4 book ai didi

java - GET 显示插入文本框的值

转载 作者:太空宇宙 更新时间:2023-11-04 07:53:30 25 4
gpt4 key购买 nike

我需要显示插入文本框中的值。我创建了这段代码:

public void onModuleLoad()
{
TextBox textValue = new TextBox();
textValue.getSelectedText();
final String index = textValue.getValue().toString();

Button button = new Button("button", new ClickHandler()
{
public void onClick(ClickEvent event)
{

Window.alert("You selected: " + index);

}
});

RootPanel.get().add(textValue);
RootPanel.get().add(button);
}

但是该值没有出现在窗口中。

有人可以帮我吗?

最佳答案

如果你想显示选定的文本,你应该使用getSelectedText,而不是getValue

试试这个

public void onModuleLoad()
{
final TextBox textValue = new TextBox();



Button button = new Button("button", new ClickHandler()
{
public void onClick(ClickEvent event)
{
final String index = textValue.getSelectedText();

Window.alert("You selected: " + index);

}
});

RootPanel.get().add(textValue);
RootPanel.get().add(button);
}

关于java - GET 显示插入文本框的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13991614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com