from one customLayout to another

my english is no very good, so i will try to do my best.

how can i from from one customLayout to another customLayout by clicking a button

login page → click by the user, then destroy de login page an create a new page.

thank you.

Hi Roberto,

I am not quite sure what you want to achieve.

Vaadin applications normally run in a single page. Take a look at this section of the
Book of Vaadin.
. Maybe this helps.

To switch from one Layout to another try something like this:


public class VaadinTests extends Application {

        @Override
        public void init() {
                final Window mainWindow = new Window("VaadinTests");
                
                HorizontalLayout layoutOne = new HorizontalLayout();
                layoutOne.addComponent(new Label("layoutOne"));
                
                HorizontalLayout layoutTwo = new HorizontalLayout();
                layoutTwo.addComponent(new Label("layoutTwo"));
                
                Button bu = new Button("Change");
                bu.addListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {
                                mainWindow.removeAllComponents();
                                mainWindow.addComponent(layoutTwo);
                        }
                });
                
                mainWindow.addComponent(layoutOne);
                
                setMainWindow(mainWindow);
                
        }
}

Haven’t tested the code myself. But it should be ok.

Kurt

It’s usually easiest to replace the root layout of the window with getWindow().setContent(newContent).

The root layout is a VerticalLayout by default, although you can use any layout (or more exactly a component container).

Marko is absolutely right.

Because Roberto stated he is a beginner, I thought, according to his statement “from one layout to another layout + button” the (not so right) example helps him to understand it a bit better.