Hi to all Vaadin Gurus and Comunity!!!
I faced with a problem with complex layout with MenuBar, HorizontalSplitPanel and tree.
I have a code:
@Override
public void init() {
Window mainWindow = new Window();
setMainWindow(mainWindow);
mainWindow.getContent().setSizeFull();
final HorizontalSplitPanel horSplit = new HorizontalSplitPanel();
MenuBar menubar = new MenuBar();
//menubar.setSizeFull(); // doesn't work
menubar.setWidth("100%"); // it's need by logic
//menubar.setHeight(20.0F, 0); // doesn't work
menubar.setImmediate(true);
menubar.addItem("File", null);
final Tree tree = new Tree("Hardware Inventory");
tree.setImmediate(true);
tree.setNullSelectionAllowed(false);
tree.setSizeFull();
final Object[][]
planets = new Object[][]
{
new Object[]{"Venus"},
new Object[]{"Earth", "The Moon"},
new Object[]{"The Moon", "Mars", "Phobos", "Deimos"},
};
for (int i=0; i<planets.length; i++) {
String planet = (String) (planets[i]
[0]
);
tree.addItem(planet);
if (planets[i]
.length == 1) {
tree.setChildrenAllowed(planet, false);
} else {
for (int j = 1; j < planets[i]
.length; j++) {
String moon = (String) planets[i]
[j]
;
tree.addItem(moon);
tree.setParent(moon, planet);
}
tree.expandItemsRecursively(planet);
}
}
horSplit.setSizeFull();
horSplit.setSplitPosition(15);
horSplit.addComponent(tree);
mainWindow.addComponent(menubar);
mainWindow.addComponent(horSplit);
}
and as result I have menubar and a lot of empty space after it before the tree, but I need the tree right after menubar.
So the main question is: what I’m doing wrong and how to make it possible
and the second one - how to avoid unnesesary scrolls in my tree widged?
Will be glad any advices and suggestions…
PS: screen in attachment