focusvaadin-flowfocuslistener

vaadin flow TextFied focus listener


I would like to have a focus listener but the way I did it shows error in IDE. My code follows

  txtField.addFocusListener(event ->{
                        
      @Override
      public void focus() {
          System.out.println("Focus");
      }
   });

Can you tell me what I am making wrong?


Solution

  • You are mixing up Java 6 and Java 8 syntaxes. You should just write

       txtField.addFocusListener(event -> {
           System.out.println("Focus");
       });