Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

как разместить окно точно поверх панели

Danila 007
8 years ago Oct 17, 2014 8:46am
dmitrii rogozin
8 years ago Oct 31, 2014 9:21am

Здравствуйте,Danila 007.
Вам нужно использовать AbsoluteLayout для этих целей. Вот пример:

protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        absLayout = new AbsoluteLayout();
        layout.setWidth("1000px");
        layout.setHeight("1000px");
        layout.setMargin(true);
        layout.setSizeFull();
        setContent(layout);

        panel = new Panel();
        panel.setWidth("300px");
        panel.setHeight("500px");

        absLayout.addComponent(panel, "left: 100px; top: 40px;");
        pos = absLayout.getPosition(panel);

        Button button = new Button("Click Me");
        button.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                Notification.show("Left pos: " + pos.getLeftValue() + " px "
                        + "Width in px" + Float.toString(panel.getWidth()));
            }
        });
        layout.addComponent(absLayout);
        layout.addComponent(button);
    }