我尝试使vaadin视图添加水平滚动条,但它没有任何结果。请你帮助我好吗。以下是我的观点的完整代码:
public class TestView extends CssLayout implements View {
/**
*
*/
private static final long serialVersionUID = 1L;
protected void init() {
Layout content = new VerticalLayout();
content.setSizeFull();
addComponent(content);
// add content to make the scrollbar appear
HorizontalLayout rightLayout = new HorizontalLayout();
for (int i = 0; i < 100; i++) {
rightLayout.addComponent(new Button("Button " + i));
}
Panel rightPanel = new Panel(rightLayout);
rightPanel.setSizeFull();
content.addComponent(rightPanel);
}
public TestView() {
super();
init();
}
@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub
}
}
答案 0 :(得分:1)
我认为你应该有Extended VerticalLayout而不是CSSLayout,所以像这样:
public class TestView extends VerticalLayout implements View {
/**
*
*/
private static final long serialVersionUID = 1L;
protected void init() {
setSizeFull();
// add content to make the scrollbar appear
HorizontalLayout rightLayout = new HorizontalLayout();
for (int i = 0; i < 100; i++) {
rightLayout.addComponent(new Button("Button " + i));
}
Panel rightPanel = new Panel(rightLayout);
rightPanel.setSizeFull();
addComponent(rightPanel);
}
public TestView() {
super();
init();
}
@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub
}
}
答案 1 :(得分:0)
我添加了监听器,它运行正常:
Page.getCurrent().addBrowserWindowResizeListener(event -> {
setWidth(UI.getCurrent().getPage().getBrowserWindowWidth(), Unit.PIXELS);
setHeight(UI.getCurrent().getPage().getBrowserWindowHeight(), Unit.PIXELS);
});