Responding immediately to an event in TextArea
It is very useful when surrounding components immediately respond to user input. For example, we can notify the user that the text in the editor has been changed. We will create a simple text area and button for saving. The button is enabled only if the value in the text area was changed as shown in the following screenshot:
How to do it...
Carry out the following steps to create a TextArea
that will immediately send an event respond:
We create a Vaadin project with a main UI class named
Demo
as follows:public class Demo extends UI {…}
We insert our text area and button to the
VerticalLayout
class. We start with creating a class namedImmediatelyTextArea
which extends theVerticalLayout
class.public class ImmediatelyTextArea extends VerticalLayout{…}
In the constructor, we create an instance of the
TextArea
class. We set this component to the immediate mode and the text change event to eager mode. It causes all text changes to be immediately fired...