Reputation: 5
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
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();
Upvotes: 0
Views: 106
Reputation: 3280
If you want change txtMailBox after each change of txtName value, you should add a value change handler to txtName (see code below).
txtName.addValueChangeHandler ( new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
final String name = event.getValue()
txtMailBox.setText(name);
}
});
Upvotes: 1