2013-11-15 1 views
-1

버튼을 드래그하여 내 버디 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(); 
    } 


} 

답변

-1

나는 그것을 할 방법을 발견하고 난 그냥 아래로 드롭 방식을 변경했다

 @Override 
     public void drop(DragAndDropEvent event) { 
      Notification.show("Dropped!"); 
      WrapperTransferable t = (WrapperTransferable) event.getTransferable(); 
      layout2.addComponent(t.getSourceComponent()); 
     } 
관련 문제