我有两个使用get的文本字段,我想将我在第一个文本字段中的文本传递到第二个文本字段
name = txtName.getText();
TextField txtName = new TextField();
txtName.setAllowBlank(false);
txtName.setEmptyText("c.gornez");
vlc.add(new FieldLabel(txtName, "Name"), new VerticalLayoutData(1, -1, new Margins(10)));
name = txtName.getText();
TextField txtMailbox = new TextField();
txtMailbox.setAllowBlank(false);
txtMailbox.setEmptyText("c.gornez");
vlc.add(new FieldLabel(txtMailbox, "Mailbox"), new VerticalLayoutData(1, -1, new Margins(10)));
mailbox = txtMailbox.getText();
答案 0 :(得分:1)
这应该有效
txtMailbox.setText(txtName.getText())
答案 1 :(得分:1)
如果您希望在每次更改 txtName 值后更改 txtMailBox ,则应将值更改处理程序添加到 txtName (见下面的代码)。
txtName.addValueChangeHandler ( new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
final String name = event.getValue()
txtMailBox.setText(name);
}
});