Css 如何对齐/移动Vaadin按钮
我正在学习Vaadin,我想将两个按钮移动到弹出窗口的底部,按钮之间留有间隔。我很确定我必须在我的主题中覆盖按钮css,但是如何在java代码中更改按钮的绝对位置呢 下面是我的代码:一个带有单击侦听器的简单按钮,它调用一个弹出方法(子窗口)。在下面的代码中,我试图将“是”按钮移动到弹出窗口的底部Css 如何对齐/移动Vaadin按钮,css,vaadin,vaadin7,vaadin6,Css,Vaadin,Vaadin7,Vaadin6,我正在学习Vaadin,我想将两个按钮移动到弹出窗口的底部,按钮之间留有间隔。我很确定我必须在我的主题中覆盖按钮css,但是如何在java代码中更改按钮的绝对位置呢 下面是我的代码:一个带有单击侦听器的简单按钮,它调用一个弹出方法(子窗口)。在下面的代码中,我试图将“是”按钮移动到弹出窗口的底部 protected void init(VaadinRequest vaadinRequest) { final VerticalLayout layout = new VerticalLayo
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
Button helloButton = new Button("Click Me");
helloButton.addClickListener(e -> helloPopUp());
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponents(helloButton);
setContent(layout);
}
private void helloPopUp() {
Window subWindow = new Window("Pop Up");
HorizontalLayout subContent = new HorizontalLayout();
AbsoluteLayout layout2 = new AbsoluteLayout();
subContent.setMargin(true);
Label text = new Label( "Hello Pop Up" , ContentMode.PREFORMATTED);
subContent.addComponent(text);
Button yes = new Button("Yes");
Button no = new Button("No");
layout2.addComponent(yes, "left: 50px; bottom: 0px;");
subContent.addComponents(layout2);
subContent.addComponent(no);
subWindow.setContent(subContent);
UI.getCurrent().addWindow(subWindow);
}
这里有一种不使用
AbsoluteLayout
private void helloPopUp() {
Window subWindow = new Window("Pop Up");
VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
Label text = new Label( "Hello Pop Up" , ContentMode.PREFORMATTED);
subContent.addComponent(text);
Button yes = new Button("Yes");
Button no = new Button("No");
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.addComponents(yes, no);
buttonsLayout.setSpacing(true);
subContent.addComponent(buttonsLayout);
subContent.setComponentAlignment(buttonsLayout, Alignment.BOTTOM_LEFT);
subWindow.setContent(subContent);
UI.getCurrent().addWindow(subWindow);
}
这里有一种不使用
AbsoluteLayout
private void helloPopUp() {
Window subWindow = new Window("Pop Up");
VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
Label text = new Label( "Hello Pop Up" , ContentMode.PREFORMATTED);
subContent.addComponent(text);
Button yes = new Button("Yes");
Button no = new Button("No");
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.addComponents(yes, no);
buttonsLayout.setSpacing(true);
subContent.addComponent(buttonsLayout);
subContent.setComponentAlignment(buttonsLayout, Alignment.BOTTOM_LEFT);
subWindow.setContent(subContent);
UI.getCurrent().addWindow(subWindow);
}
我会对内容使用垂直布局,然后将这两个按钮放入它们自己的水平布局中,并在该布局上使用setspace(true)。然后在垂直布局上使用setComponentAlignment将水平对齐设置为右下角。我会对内容使用垂直布局,然后将两个按钮放入它们自己的水平布局中,并在该布局上使用setSpacing(true)。然后在垂直布局上使用setComponentAlignment将水平对齐设置为右下角。