Closing subwindows and listeners question

Hello dear fellows,

i’m working with vaadin at the moment and have encountered a problem, which i don’t know how to solve at the moment.
I’ve created an application, which has a mainWindow. The mainWindow is set to setSizeFull(). Inside the mainWindow i have a VerticalLayout, which again contains a Panel-component and is a separated class. The Panel-component has a Button-component, that opens a subWindow. The subWindow (again an separated own class) can be used to edit things and then you can press the save or cancel button. When pressing one of these buttons the subWindow is closed via the close()-Method.

Now to my problem:
When the subWindow is closed i want the Panel beeing refreshed, what does not work. Here is some code to explain my problem:

class X extends VerticalLayout implements Window.CloseListener {
 Panel p = new Panel();
 Button b = new Button("Open subWindow");

 private void initComponents() {
  b.addListener(new Button.ClickListener() {
       @Override
	public void buttonClick(ClickEvent event) {
		editSomething("Edit Me");
	}
  });

 p.addComponent(b);
 ...
 this.addComponent(p);
 }

 private void editSomething(String something) {
        Editor editor = new Editor("Edit Something", true);
        editor.showEditor();
    }

 private void refreshPanel() {
  // refresh Panel ... for example: show the edited text
 }

 @Override
 public void windowClose(CloseEvent e) {
		refreshPanel();
 }
}

class Editor extends Window {
 ...
 public void showEditor() {
        if (getParent() == null) {
            getMainWindow().addWindow(this);
        }
    }

 public void closeEditor() {
    	this.close();
    }
}

The Panel contains more, which should be refreshed, not only the button, but i think it’s meaningless to show it here :slight_smile:

So it seems for me that the Panel is never refreshed, when the subWindow is closed and i’m wondering why? Anyone can help me here?
Thanks.

I don’t see any code that adds a CloseListener to the editor window.

You’d probably need to add editor.addListener(this); to the editSomething method.

Oops, seems like I’ve totaly forgotten that! :slight_smile:
Thank you very much, works like a charm now!