A DockModel contains the structure of all the Dock and Dockable objects that are used in an application. It contains also the Visualizers that are used in the application.
The structure of docks and dockables in an application is like this:
LeafDock leafDock = dockable.getDock();
CompositeDock parentDock = dock.getParentDock();
You have to give all the java.awt.Window objects (javax.swing.JFrame or javax.swing.JDialog), where you will put docks to the dock model with a unique ID.
When you add a root dock to the model you have to specify its ancestor window:// Create the dock model for the docks. FloatDockModel dockModel = new FloatDockModel(); dockModel.addOwner("frame0", frame);
When you add a visualizer (minimizer or maximizer) to the model you have to specify its window:// Add the root dock to the dock model. dockModel.addRootDock("totaldock", totalSplitDock, frame);
// Add the maximizer to the dock model. dockModel.addVisualizer("maximizer", maximizer, frame); ... // Add the minimizer to the dock model. dockModel.addVisualizer("minimizer", minimizer, frame);
The most used DockModel implementation is the FloatDockModel. This dock model creates by default a FloatDock for every owner window, that you add to the model.
You can give a FloatDockFactory to your float dock model. This factory will be used to create your custom float docks.
{ ... // Create the factory for the float docks. FloatDockFactory floatDockFactory = new MyFloatDockFactory(); // Create the dock model for the docks. FloatDockModel dockModel = new FloatDockModel(floatDockFactory); ... } private class MyFloatDockFactory extends DefaultFloatDockFactory { public FloatDock createFloatDock(Window owner) { FloatDock floatDock = super.createFloatDock(owner); // We want a higher priority for making dockables float. floatDock.setDockPriority(DockPriority.CAN_DOCK_WITH_PRIORITY); return floatDock; } }
CodecExample | Shows the usage, the encoding, and the decoding of dock models. |
WorkspaceExample | Shows the usage, the encoding, and the decoding of dock models. |