これにはJavaScriptとカスタムロジックが必要だと思います。
まず、メイン レイアウト ID を設定する必要があります。
mainLayout.setId("xyz");
そして、ここに拡張ウィンドウがあります:
public class MyWindow extends Window {
private static final long serialVersionUID = 1L;
private int top;
private int left;
private int bottom;
private int right;
public MyWindow() {
setResizable(false);
setData(WindowMode.NORMAL);
String sourceURL = "javascript:com.xyz.foo.myfunc(" +
"document.getElementById('xyz').getBoundingClientRect().top," +
"document.getElementById('xyz').getBoundingClientRect().left," +
"document.getElementById('xyz').getBoundingClientRect().bottom," +
"document.getElementById('xyz').getBoundingClientRect().right)";
final Link link = new Link("maximization", new ExternalResource(sourceURL));
// set link icon if needed
JavaScript.getCurrent().addFunction("com.xyz.foo.myfunc", new JavaScriptFunction() {
private static final long serialVersionUID = 1L;
@Override
public void call(JSONArray arg) throws JSONException {
if (MyWindow.this.getData() == WindowMode.NORMAL) {
saveCurrentPos();
setPos(arg.getInt(0), arg.getInt(1), arg.getInt(2), arg.getInt(3));
link.setCaption("normalization"); // or set icon
MyWindow.this.setData(WindowMode.MAXIMIZED);
} else {
setPos(top, left, bottom, right);
link.setCaption("maximization"); // or set icon
MyWindow.this.setData(WindowMode.NORMAL);
}
}
});
VerticalLayout vLayout = new VerticalLayout(link);
vLayout.setComponentAlignment(link, Alignment.TOP_RIGHT);
setContent(vLayout);
// demo settings
setWidth("200px");
setHeight("150px");
center();
}
private void saveCurrentPos() {
left = getPositionX();
top = getPositionY();
right = left + (int) getWidth();
bottom = top + (int) getHeight();
}
private void setPos(int top, int left, int bottom, int right) {
setPositionX(left);
setPositionY(top);
setWidth(right - left, Unit.PIXELS);
setHeight(bottom - top, Unit.PIXELS);
}
}
キャプションと閉じるボタンを含む独自のヘッダーを作成することをお勧めします。