0

I know it's a basic question... But I'm still learning and I don't know what's happening !

I created a vaadin 8 project with Eclipse. I used this link to create some components : https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20login%20view

But I would like to add :

Button sample = new Button("Click");
sample.addClickListener(event -> Notification.show("The button was clicked", Type.TRAY_NOTIFICATION));

But the method addClikcListener is not reconized !

EDIT :

Yes, I can do :

Button sample = new Button("Click", new Button.ClickListener() {
    private static final long serialVersionUID = 1L;

    @Override
    public void buttonClick(ClickEvent event) {
    }
)};

EDIT 2 : The error is :

Syntax error on token ".", @ expected after this token  SimpleLoginMainView.java    
Bob
  • 529
  • 1
  • 7
  • 28
  • Don't know Vaadin, but it appears you can add listeners via the second argument to the `Button` constructor. Try that. – Carcigenicate Mar 16 '17 at 19:05
  • I edited the post to add the example. Yes, but I tried to understand why it's not working direcly... because I cannot use any method on my button... – Bob Mar 16 '17 at 19:11
  • Thanks for your help. I'm trying to understand why I cannot use this method. It's strange, isn't it? – Bob Mar 16 '17 at 19:16
  • 1
    My thought was it may have been removed. I couldn't verify that though as the vaadin site is down currently. – Carcigenicate Mar 16 '17 at 19:21
  • I'm blocked too because it's down ! – Bob Mar 16 '17 at 19:33
  • Ya. Unfortunate timing. I was able to find examples on other sites that verify your code does appear to be valid, but without an official source, it's hard to say. Also, again, I hadn't even heard of Vaadin before reading this question, so I'm just shooting in the dark. Good luck. – Carcigenicate Mar 16 '17 at 19:35
  • Also, please post the **exact** error. Sometimes key details get missed when you manually write them. – Carcigenicate Mar 16 '17 at 19:36
  • Which `.` is the error happening on? And that's a very different error than what you originally said it was. That error doesn't suggest that `addClickListener` doesn't exist, it suggests a syntax error. – Carcigenicate Mar 16 '17 at 19:54
  • You seem to have top-level expressions in a class. Is `Button sample = new Button("Click");` inside a method? – Carcigenicate Mar 16 '17 at 19:56
  • Could you add that as answer? Yeah... I don't know how I can do that... but yes.... I did bad bad bad mistake ! And yes it's a duplication because it's the same error and same resolution ! Thanks for your help! – Bob Mar 17 '17 at 08:38
  • If it is a dupe, doesn't the other answer answer the question? – Carcigenicate Mar 17 '17 at 13:25
  • @FannyV Remove the second argument from your addClickListener. – Henri Kerola Mar 17 '17 at 17:32

0 Answers0