Code:
private boolean k = true; private VLayout layout = null; public void onModuleLoad() { layout = new VLayout(); layout.setWidth100(); layout.setHeight100(); layout.setAnimateMembers(true); Window win = new Window(); win.setAutoSize(true); win.setWidth("50%"); win.setHeight(1); final Label label = new Label("AAA"); label.setBackgroundColor("red"); label.setShowEdges(true); label.setWidth(50); label.setHeight(80); win.addItem(label); layout.addMember(win); IButton button = new IButton("Size"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { f(k) { Canvas[] cnvases = layout.getMembers(); for(Canvas canvas : cnvases) { try { Window box = (Window)canvas; Label label2 = (Label)box.getItems()[0]; label2.setHeight(50); } catch(ClassCastException e) { } } k = false; } else { Canvas[] cnvases = layout.getMembers(); for(Canvas canvas : cnvases) { try { Window box = (Window)canvas; Label label2 = (Label)box.getItems()[0]; label2.setHeight(80); } catch(ClassCastException e) {} } k = true; } } }); IButton button2 = new IButton("Add"); button2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window win2 = new Window(); win2.setAutoSize(true); win2.setWidth("50%"); win2.setHeight(1); final Label label = new Label("AAA"); label.setBackgroundColor("red"); label.setShowEdges(true); label.setWidth(50); label.setHeight(80); win2.addItem(label); layout.addMember(win2); } }); layout.addMember(button); layout.addMember(button2); layout.draw(); }
I've noticed strange behavior of the window object which is recreated by the code above. "Size" button changes the height of the label inside layout and in turn, it causes a change of window's height. If the window is added to layout during the initialization, it is ok. However, if I add new window using "Add" button and then use "Size", only the height of label is changed. Window's height remains the same. It turned out that the problem disappears if I remove layout.setAnimateMembers(true); Is it possible to fix this issue?
SmartGwt v.2.4