drop handler not working for DDLayouts

I can’t get the destination layout(DDHorizntalLayout) to accept the custom component from a DDGridLayout. Here is a snippet of the code:

		public AcceptCriterion getAcceptCriterion()
			return AcceptAll.get();
		public void drop(DragAndDropEvent event)
                            LayoutBoundTransferable t = (LayoutBoundTransferable) event.getTransferable();
			Component c = t.getComponent();

The source layout is a DDGridLayout:

DDGridLayout facesGrid;

PictureInfo currPic = new PictureInfo(new Label(name), cb, img);

I see it being dragged but it won’t stay in the DDHorizontalLayout. I also see it hit the AcceptCriterion.

One thing I can think of (at least I didn’t see it in your code) is that you are not detaching the custom component from the grid layout before attaching it to the horizontal layout. At least for me this example works:

DDGridLayout grid = new DDGridLayout();
DDHorizontalLayout horizontal = new DDHorizontalLayout();
horizontal.setDropHandler(new DropHandler() {
	public AcceptCriterion getAcceptCriterion() {
			return AcceptAll.get();
	public void drop(DragAndDropEvent event) {
		LayoutBoundTransferable transferable = (LayoutBoundTransferable)event.getTransferable();
		HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails();
		Component c = transferable.getComponent();
		// Detach from parent layout
		// Add to target layout (ignores position)

With the addon comes a default implementation of a DDHorizontalLayout drophandler,
, which does this and also takes into consideration the drop location and special cases. Take a look at it for an example.

Note: The released version of DefaultHorizontalLayoutDropHandler.java (0.6.3) contains a couple of typos which has been fixed after the release so don’t use it directly, instead use the version in the repository. The fixed version will be included in the next release (0.6.4)

My Buttons in GridLayout is not draggable.
Here is my code
public class DragDropGridLayoutDemo {

private static final long serialVersionUID = 1L;

private static final int COLUMNS = 4;

private static final int ROWS = 4;

public DragDropGridLayoutDemo() {


public Component getLayout() {

    // start-source

    DDVerticalLayout outer = new DDVerticalLayout();



    outer.setDropHandler(new DefaultVerticalLayoutDropHandler());

    Label lbl = new Label("This is a grid layout with 16 cells, try dragging the buttons into an empty cell");


    // Create a drag and droppable grid layout

    final DDGridLayout layout = new DDGridLayout(COLUMNS, ROWS);



    // Only allow dropping in the center of the grid layout cell




    outer.setExpandRatio(layout, 1);

    // Enable dragging components


    // Enable dropping components

    layout.setDropHandler(new DefaultGridLayoutDropHandler());

    for (int row = 0; row < ROWS; row++) {

        for (int col = 0; col < COLUMNS; col++) {

            if (row == 0 || row == ROWS - 1 || col == 0 || col == COLUMNS - 1) {

                Button btn = new Button("Button");

                layout.addComponent(btn, col, row);

                layout.setComponentAlignment(btn, Alignment.MIDDLE_CENTER);




    // end-source

    return outer;



Have you compiled the widgetset?

No I am not .

Actually I am not using GWT ,

DragDroplayouts contains client side GWT code that needs to be compiled into the widgetset. If you want to use it you need to replace DefaultWidgetset with your own widgetset.

The same goes for most addons in the Directory.