Dragging-and-dropping between different layouts
Each layout has a different wrap behavior. If we want to try this behavior for ourselves, we will have to create a simple demo. In this demo, we can drag-and-drop components between the four different layouts. We can also change the size of each layout by moving the separator and watch how components are wrapped. If the line cannot be wrapped, a scroll bar appears.
How to do it...
Carry out the following steps to create a drag and drop panel:
We create project with the root
Demo
class.public class Demo extends UI {…}
All four layouts will be inserted into the
DragndropPanel
class that extendsHorizontalSplitPanel
.public class DragndropPanel extends HorizontalSplitPanel {…}
Now let's insert the
createLayout()
method. In this method we add buttons to the layout that is taken over theAbstractLayout
parameter. Next we wrap this layout by theDragAndDropWrapper
class and setDropHandler
. Here we implement two methods. First isgetAcceptCriterion()
...