{
final TextField tf = new TextField("Debug");
getLayout().addComponent(tf);
tf.addListener(new TextChangeListener() {
@Override
public void textChange(TextChangeEvent event) {
System.err.println(tf.getCaption() + " textChange");
}
});
tf.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
System.err.println(tf.getCaption() + " valueChange");
}
});
tf.addListener(new BlurListener() {
@Override
public void blur(BlurEvent event) {
System.err.println(tf.getCaption() + " blur");
}
});
tf.addListener(new FocusListener() {
@Override
public void focus(FocusEvent event) {
System.err.println(tf.getCaption() + " focus");
}
});
}
{
final TextField tf = new TextField("Label");
getLayout().addComponent(tf);
final Label l = new Label();
getLayout().addComponent(l);
tf.addListener(new TextChangeListener() {
@Override
public void textChange(TextChangeEvent event) {
l.setValue(event.getText());
}
});
tf.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
System.err.println(tf.getCaption() + " valueChange");
}
});
}
{
final TextField tf = new TextField("Slow label");
tf.setTextChangeTimeout(2000);
tf.setImmediate(true);
getLayout().addComponent(tf);
final Label l = new Label();
getLayout().addComponent(l);
tf.addListener(new TextChangeListener() {
@Override
public void textChange(TextChangeEvent event) {
l.setValue(event.getText());
}
});
tf.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
System.err.println(tf.getCaption() + " valueChange");
}
});
}
{
final TextField tf = new TextField("Uppercase");
tf.setTextChangeTimeout(1);
getLayout().addComponent(tf);
final Label l = new Label();
getLayout().addComponent(l);
tf.addListener(new TextChangeListener() {
@Override
public void textChange(TextChangeEvent event) {
tf.setValue(event.getText().toUpperCase());
}
});
tf.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
System.err.println(tf.getCaption() + " valueChange");
}
});
}
{
final TextField[] tfs = new TextField[] { new TextField(),
new TextField(), new TextField(), new TextField() };
HorizontalLayout hl = new HorizontalLayout();
hl.setCaption("Blää");
getLayout().addComponent(hl);
for (TextField tf : tfs) {
tf.setColumns(4);
tf.setTextChangeEventMode(TextChangeEventMode.EAGER);
hl.addComponent(tf);
tf.addListener(new TextChangeListener() {
@Override
public void textChange(TextChangeEvent event) {
String txt = event.getText();
int len = txt.length();