Panel not full screen

Hello

I’m building my first vaadin application. I love it so far, but I have one problem.

Panel is not full screen. How do I change it to full screen view?


package com.example.mywebpage;

import com.vaadin.Application;
import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Tree;
import com.vaadin.ui.Window;

public class MywebpageApplication extends Application {
	/**
	 * 
	 */
	
	/**
	 * 
	 */

	@Override
	public void init() {
		Window mainWindow = new Window("Matej Pikovnik | Java developer");

		mainWindow.addComponent(mainUI());
		setMainWindow(mainWindow);
	}

	public Component mainUI() {
		HorizontalLayout hLayout = new HorizontalLayout();
			hLayout.setSizeFull();
			
		
		TabSheet tSheet = new TabSheet();
		tSheet.setHeight(100, Sizeable.UNITS_PERCENTAGE);
		tSheet.setWidth(100, Sizeable.UNITS_PERCENTAGE);
		
		tSheet.addTab(AboutMe()).setCaption("About me");
		tSheet.addTab(MyWork()).setCaption("My work");
		tSheet.addTab(AboutMe()).setCaption("Contact me");
		

		hLayout.addComponent(tSheet);
		hLayout.setSpacing(true);
		hLayout.setSizeFull();	
		
		return hLayout;
	}

	

	public Component AboutMe() {
		Panel about = new Panel();
			about.setWidth(100, Sizeable.UNITS_PERCENTAGE);
			about.setHeight(100, Sizeable.UNITS_PERCENTAGE);
		
		Label meLabel = new Label();
		
		meLabel.setHeight(100, Sizeable.UNITS_PERCENTAGE);
		meLabel.setWidth(100, Sizeable.UNITS_PERCENTAGE);
		meLabel.setValue("Mtabgaefda");
		
		about.addComponent(meLabel);
		about.setSizeFull();
		return about;
	}
	
	public Component MyWork()
	{
		
		Panel p = new Panel();
		HorizontalSplitPanel hsPanle = new HorizontalSplitPanel();
		
		p.setContent(hsPanle);
				
		final Object[][]
 planets = new Object[][]
{
		        new Object[]{"Android", "Working Days", "Coupon Calculator", "Fartoid"},    
		        new Object[]{"Vaadin", "This page", "TKO Litija"},
		        new Object[]{"iOS", "Io", "Europa", "Ganymedes", "Callisto"}};
		        
		Tree tree = new Tree("My work");

		/* Add planets as root items in the tree. */
		for (int i=0; i<planets.length; i++) {
		    String planet = (String) (planets[i]
[0]
);
		    tree.addItem(planet);
		    
		    if (planets[i]
.length == 1) {
		        // The planet has no moons so make it a leaf.
		        tree.setChildrenAllowed(planet, false);
		    } else {
		        // Add children (moons) under the planets.
		        for (int j=1; j<planets[i]
.length; j++) {
		            String moon = (String) planets[i]
[j]
;
		            
		            // Add the item as a regular item.
		            tree.addItem(moon);
		            
		            // Set it to be a child.
		            tree.setParent(moon, planet);
		            
		            // Make the moons look like leaves.
		            tree.setChildrenAllowed(moon, false);
		        }

		        // Expand the subtree.
		        tree.expandItemsRecursively(planet);
		    }
		}

		
		
		hsPanle.setFirstComponent(tree);
		
		hsPanle.setSecondComponent(new Label("Just test"));
		
		return p;
	}
	

}

You can see my page here:


Pic1


Pic2


pic3

Windows have a root layout and addComponent() adds components to that layout. If you want to have your application take full screen, you also have to set the root layout to full size.

You can do either:

[list]

[]
[tt]
mainWindow.getContent().setSizeFull();
[/tt] or
[
]
[tt]
yourRootLayout.setSizeFull(); mainWindow.setContent(youRootLayout);
[/tt]

[/list]See Book section:
Window and Panel Root Layout
.

Thank you very much. One more problem If u can help me.

in my work window i have Tree I would like to create Listener so that if I click Item on right side shows up name of item.

I’ve tried Property.ValueChangeListener but did not succseed.

Thank you in advance

Can you describe or show some code on what you have tried?

You probably forgot to set the Tree to immediate mode (Tree.setImmediate(true)) so you get selection events without delays.