Expanding or shrinking size of vaadin calendar component in subwindow

The size of

Calendar component

in subwindow doesn’t
expand
or
shrink
to fit the size of subwindow when i click on
maximize
or
minimize
button in subwindow.

So i have to click on random button or combobox for vaadin calendar component to fit perfectly in subwindow.

Here are
pictures
that show my problem
(pictures can be view on stackoverflow, here is the link):


http://stackoverflow.com/questions/37052108/expanding-or-shrinking-size-of-vaadin-calendar-component-in-subwindow


Code for opening a subWindow:

[code]

Window abonWindow = new Window(“Abonma”);
abonWindow.setImmediate(true);
abonWindow.setHeight(“450px”);
abonWindow.setWidth(“700px”);
abonWindow.setModal(true);
abonWindow.setContent(new AddAbonma(abonWindow));

                        UI.getCurrent().addWindow(abonWindow);

[/code]


I add all compontents in subwindow with this code:

    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(true);
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    
    setWidth("100.0%");
    setHeight("100.0%");
    
    
    initCalendar();
    initLayoutContent();
    initSettingPopupview();
    
    
    panel_criteria = buildPanel_criteria();
    mainLayout.addComponent(panel_criteria, "right:0.0px;top:0.0px;left:0.0px;");
    
    mainLayout.addComponent(calendarComponent, "right:0.0px;top:70.5px;bottom:0px;left:0.0px;");

initCalendar code:

     calendarComponent.setLocale(new Locale("sl","SL"));
                    calendarComponent.setImmediate(true);
                    calendarComponent.setHeight("100%");
                    calendarComponent.setWidth("100%");


This is all code that i have in constructor of SubWindow, i put also addWindowModeChangeListener in it:

   buildMainLayout();
    setCompositionRoot(mainLayout);
    initGui(window);
    window.addWindowModeChangeListener(new WindowModeChangeListener() {
        
        @Override
        public void windowModeChanged(WindowModeChangeEvent event) {
            
            System.out.println("AddAbonma WindowMode");
            
            if(calendarComponent!=null){
                
                calendarComponent.markAsDirtyRecursive();
        
            }
            
        }
    });  

This approach worked with tables, but does not work with vaadin calendar component.

So how do i expand or shrink vaadin calendar component to fit the
subwindow
when user click on maximize or minimize button?


Work around to solve this problem
(link to stackoverflow:
http://stackoverflow.com/questions/37052108/expanding-or-shrinking-size-of-vaadin-calendar-component-in-subwindow/37073606#37073606
).

Maybe someone will face the simulare trouble, here is the
solution
:

You can force Vaadin to recalculate layout with JavaScript. This should not be required and behavior you describe looks like a bug in Vaadin.

You can try something like this. This uses arbitrary timeout of 150 ms because layout recalculating cannot be requested while Vaadin LayoutManager is working and we want to force layout after Vaadin has handled window resizing (and failed to calculate layout)

calculate layout).Window window = new Window(); 
Calendar calendar = new Calendar("Calendar"); 
calendar.setWidth("100%"); 
window.setWidth("700px"); 
window.setHeight("450px"); 
window.setContent(calendar);
 window.addWindowModeChangeListener(event -> 
 Page .getCurrent() .getJavaScript() .execute("setTimeout(function() { vaadin.forceLayout(); }, 150);")); 
 Button button = new Button("Click me", event -> UI.getCurrent().addWindow(window)); setContent(button);