A CompositeDock is a Dock that contains other docks. It does not contain dockables. The child docks can also be composite docks.
If you want to use a composite dock, you have to do the folowing things:
The most used composite dock is the SplitDock. This composite dock can contain 0, 1, or 2 child docks. When there are 2 child docks, they are split by a divider. In the folowing example a split dock is created with one child dock:
The only child dock is put in the center of the split dock.// Create the child tab dock. TabDock tabDock = new TabDock(); // Add the dockables to the tab dock. tabDock.addDockable(dockable1, new Position(0)); tabDock.addDockable(dockable2, new Position(1)); tabDock.addDockable(dockable3, new Position(2)); tabDock.addDockable(dockable4, new Position(3)); // Create the split dock. SplitDock splitDock = new SplitDock(); // Add the child dock in the center of the split dock. splitDock.addChildDock(tabDock, new Position(Position.CENTER));
In the folowing example a split dock is created with two child docks:
You can also put the children at the top and bottom:// Create the child tab dock. TabDock leftTabDock = new TabDock(); TabDock rightTabDock = new TabDock(); // Add the dockables to the tab docks. leftTabDock.addDockable(dockable1, new Position(0)); leftTabDock.addDockable(dockable2, new Position(1)); rightTabDock.addDockable(dockable3, new Position(0)); rightTabDock.addDockable(dockable4, new Position(1)); // Create the split dock. SplitDock splitDock = new SplitDock(); // Add the child docks to the split dock. splitDock.addChildDock(leftTabDock, new Position(Position.LEFT)); splitDock.addChildDock(rightTabDock, new Position(Position.RIGHT)); splitDock.setDividerLocation(290);
// Add the child docks to the split dock. splitDock.addChildDock(leftTabDock, new Position(Position.TOP)); splitDock.addChildDock(rightTabDock, new Position(Position.BOTTOM)); splitDock.setDividerLocation(190);
A special composite dock is the FloatDock. This dock is not a java.awt.Component. Its child docks are the docks in floating windows.
If you are working with a FloatDockModel, then you don't have to create the float dock by yourself. This model creates a float dock for every owner window that you add. You can retrieve this float dock with the folowing code:
Add the child docks to the floatdock. The positions in float docks are 3-dimensional (x-position, y-position, z-order).// Get the float dock. This is a standard dock of the floating dock model. FloatDock floatDock = dockModel.getFloatDock(windowId);
When a dockable is dragged, and when no other dock is found to dock the dockable, only then the dockable will be docked in the float dock. If you want a higher priority to let dockables float, then you have to augment the dock priority of the float dock:// Add the child docks to the float dock. floatDock.addChildDock(singleDock1, new Position(x, y, 0)); floatDock.addChildDock(singleDock2, new Position(x + 50, y + 50, 1));
floatDock.setDockPriority(DockPriority.CAN_DOCK_WITH_PRIORITY);
A composite dock has always a DockFactory to create its child docks.
When you drag a dockable above a composite dock and you release the mouse, then the dockable can be added to the composite dock. The folowing things will be done by the docking functionality:
floatDock.setChildDockFactory(new SingleDockFactory());
A special composite dock is a CompositeLineDock. It organizes its child docks in a line.
In the folowing example 2 horizontal composite line docks are created. They have a TabDockFactory as child dock factory.
// Create the composite line docks. CompositeLineDock lineDock1 = new CompositeLineDock( CompositeLineDock.ORIENTATION_HORIZONTAL, true, new TabDockFactory()); CompositeLineDock lineDock2 = new CompositeLineDock( CompositeLineDock.ORIENTATION_HORIZONTAL, true, new TabDockFactory()); // Add the child docks to the composite dock. lineDock1.addChildDock(tabDock1, new Position(0)); lineDock1.addChildDock(tabDock2, new Position(1)); lineDock1.addChildDock(tabDock3, new Position(2)); lineDock2.addChildDock(tabDock4, new Position(0)); lineDock2.addChildDock(tabDock5, new Position(1)); lineDock2.addChildDock(tabDock6, new Position(2));
Another special composite dock is a CompositeGridDock. It organizes its child docks in a grid.
In the folowing example a composite grid dock is created. It has a SingleDockFactory as child dock factory.
// Create the grid dock. CompositeGridDock gridDock = new CompositeGridDock(new SingleDockFactory()); // Add the child docks to the composite dock. gridDock.addChildDock(dock1, new Position(0)); gridDock.addChildDock(dock2, new Position(1)); gridDock.addChildDock(dock3, new Position(2)); gridDock.addChildDock(dock4, new Position(3)); gridDock.addChildDock(dock5, new Position(4)); gridDock.addChildDock(dock6, new Position(5));
| SplitDockWithOneChild | Shows the use of split docks. |
| SplitDockWithTwoChildren | Shows the use of split docks. |
| FloatChildDocks | Shows the use of float docks. |
| CompositeLineDocks | Shows the use of composite line docks. |
| CompositeGridDocks | Shows the use of composite grid docks. |