我试图拖动一个按钮并将其放在我的 vaadin ui 中的另一个布局。但它不起作用。它不会改变位置到我放下它的位置。下面是我的代码。任何帮助都很棒。
public class TestDrag extends VerticalLayout implements View {
@Override
public void enter(ViewChangeEvent event) {
setSizeFull();
addStyleName("stores");
HorizontalLayout layout1=new HorizontalLayout();
Button button=new Button("Save");
DragAndDropWrapper draggable = new DragAndDropWrapper(button);
draggable.setDragStartMode(DragStartMode.COMPONENT);
draggable.setSizeFull();
layout1.addComponent(draggable); // add it to some layout
addComponent(layout1);
HorizontalLayout layout2=new HorizontalLayout();
layout2.setSizeFull();
Button button1=new Button("Cancel");
layout2.addComponent(button1);
DragAndDropWrapper destiny = new DragAndDropWrapper(
layout2);
addComponent(destiny);
destiny.setDropHandler(new DropHandler() {
@Override
public AcceptCriterion getAcceptCriterion() {
return AcceptAll.get();
}
@Override
public void drop(DragAndDropEvent event) {
Notification.show("Dropped!");
}
});
destiny.setSizeFull();
}
}