[SOLVED] Book of Vaddin , Window.CloseEvent

Hi,
I jsut started with the Book of Vaddin and encountered some issue.

When trying to implement the following code:


package com.example.myapplication;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Window.CloseEvent;

public class MyApplication extends Application implements Window.CloseListener{
			//ERROR A
	private static final long serialVersionUID = 1L;

	@Override
	public void init() {
		Window mainWindow = new Window("MyApplication");
		setMainWindow(mainWindow);
		mainWindow.addComponent(new WindowOpener("Window Opener", mainWindow));

		// Close the application if the main window is closed.
		mainWindow.addListener(new Window.CloseListener(){
		  	
			private static final long serialVersionUID = 1L;
			@Override
			public void windowClose(CloseEvent e) { //ERROR B
			       System.out.println("Closing the application");
			       getMainWindow().getApplication().close();
			    } 
		});	
	}
}

I get the following errors( see code)

ErrorA:
The type MyApplication must implement the inherited abstract method Window.CloseListener.windowClose(Window$CloseEvent)

ErrorB:
Multiple markers at this line
- The method windowClose(Window.CloseEvent) of type new Window.CloseListener(){} must override a superclass
method
- implements com.vaadin.ui.Window.CloseListener.windowClose

What am I missing ?

Hi,

Two thing to fix this problem :

  1. remove “implements…” in the class declaration. (because you create an anonymous listener and the application class no longer need to implement CloseListener)
  2. remove the overrideAnnotation. (I hate when Eclipse bug me like this !)

Hope it’s help.

Regards.

Éric

Thank you ! I keep reading that “magic” book now :slight_smile: