如何在Vaadin中的RichTextArea中添加TextChangeListener

时间:2015-05-07 08:23:19

标签: vaadin richtextarea

TextField searchField = new TextField();
searchField.addTextChangeListener(new TextChangeListener() {
    @Override
    public void textChange(TextChangeEvent event) {
        updateCharecterLeft();
    }
});

我想要一个RichTextArea而不是searchField。但RichTextArea没有addTextChangeListener。请帮忙

2 个答案:

答案 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() 
        }       
});