TextField searchField = new TextField();
searchField.addTextChangeListener(new TextChangeListener() {
@Override
public void textChange(TextChangeEvent event) {
updateCharecterLeft();
}
});
我想要一个RichTextArea而不是searchField。但RichTextArea没有addTextChangeListener。请帮忙
答案 0 :(得分:0)
RichTextArea改为使用addValueChangeListener()方法,该方法继承自AbstractField。
RichTextArea richTextArea = new RichTextArea();
richTextArea.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
updateCharecterLeft();
}
});
答案 1 :(得分:0)
试试这个:
textArea.setImmediate(true);
textArea.setTextChangeEventMode(TextChangeEventMode.EAGER);
textArea.addTextChangeListener(new TextChangeListener(){
@Override
public void textChange(TextChangeEvent event) {
// use event.getText()
}
});