不知道你在做什么,但是这个来自一个新的 Maven 项目的非常基本的例子是有效的。单击按钮时,文本输入字段会消失
@Theme("mytheme")
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
final TextField name = new TextField();
name.setCaption("Type your name here:");
GridLayout gl= new GridLayout(2,2);
gl.addComponent(new Label("GL 1.1"));
gl.addComponent(new Label("GL 1.2"));
gl.addComponent(new Label("GL 2.1"));
gl.addComponent(new Label("GL 2.2"));
Button button = new Button("Click Me");
button.addClickListener(e -> {
layout.addComponent(new Label("Thanks " + name.getValue()
+ ", it works!"));
Animator.animate(gl, new Css().opacity(0));
Animator.animate(gl, new Css().translateX("100px")).delay(1000).duration(5000);
});
layout.addComponents(name, button);
setContent(layout);
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}