w.addWindowModeChangeListener(new WindowModeChangeListener() {
@Override
public void windowModeChanged(WindowModeChangeEvent event) {
WindowMode state = (event.getWindow().getWindowMode());
if (state == WindowMode.NORMAL) {
w.setCaption("Window " + w.getData() + " Normal");
maximize.setCaption("Maximize");
} else if (state == WindowMode.MAXIMIZED) {
w.setCaption("Window " + w.getData() + " Maximized");