Vaadin switching between views on button click

When i create a new vaadin application i get the default main window in which i can add ui components and get going. I wanted to visual edit that main window with the eclipse visual designer but unfortunately i could not figure that out. Instead i created a new composite (login window) and then created an instance of that in my main application adding that composite as a component to my main window. First, is it a good idea to create multiple composites (header, mainView, PatientView…) and show them on button clicks moving from one composite to another, if so how can i create switch between each one of these using button click event listener’s?

The basic technique is to use getMainWindow().setContent() to set a new root layout or composite with the new view. You can set a composite component (CustomComponent) as the root component, as setContent() accepts any ComponentContainer.

A common way is to use the
View Manager pattern
to switch between views. The
AppFoundation
add-on provides one implementation, although you can easily implement it on your own to suit your needs, as is done
here
(see
here
and in view files in the example project for examples on using it).

For example:

Button register = new Button(app.getMessage(GasDiaryMessages.RegisterNewUser));
register.setStyleName("link");
register.addListener(new Button.ClickListener() {
    public void buttonClick(ClickEvent event) {
        // Switch to the registration screen
        app.getViewManager().pushScreen(RegistrationScreen.class.getName(),
                new RegistrationScreen(app));
    }
});

Should i be copying the viewmanager class and using it in the mainWindow class created at the start of the application or inside my composite class where i have layed out all of my UI components. I am having trouble changing properties of those components, why is it so hard to change the background color, image on a button?

i have a condition to be checked in the if loop, if condition is true i would like to change to the other view.
Is their any variable ui.setContent() which leads me to the other view ? or do i need to do it in any other way ?