[英]passing textfield value from another textfield in java
I have two textfields using gwt and I would like to pass the text that I have in my first textfield in to my second textfield 我有两个使用gwt的文本字段,我想将第一个文本字段中的文本传递给第二个文本字段
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();
这应该工作
txtMailbox.setText(txtName.getText())
If you want change txtMailBox after each change of txtName value, you should add a value change handler to txtName (see code below). 如果你想txtName的值的每次更改后改变txtMailBox,你应该添加值的变化处理程序 txtName的 (见下面的代码)。
txtName.addValueChangeHandler ( new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
final String name = event.getValue()
txtMailBox.setText(name);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.