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

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

4

2 回答 2

0

RichTextArea具有 addValueChangeListener() 方法,该方法继承自AbstractField

RichTextArea richTextArea = new RichTextArea();
    richTextArea.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            updateCharecterLeft();
        }
    });
于 2015-05-07T10:22:15.620 回答
0

尝试这个 :

textArea.setImmediate(true);
textArea.setTextChangeEventMode(TextChangeEventMode.EAGER);
textArea.addTextChangeListener(new TextChangeListener(){

        @Override
        public void textChange(TextChangeEvent event) {
            // use event.getText() 
        }       
});
于 2017-03-22T12:51:08.657 回答