![]() |
||||||||||||||
|
Eleritec Docking Framework Tutorial
|
||||||||||||||
|
||||||||||||||
|
A BorderManager Example
The provided border management example consists of three classes; BorderDemo.java, DemoBorderManager.java, and
DockablePanel.java. They have been separated out into multiple classes based upon logical function
to help demonstrate how custom border management might be included into a more extensive application.
BorderDemo.java is the main class responsible for constructing the application. It instantiates a JFrame, adds several DefaultDockingPorts to the content pane, and docks a series of docking-enabled panels into a preconfigured layout. The construction code in this class is very similar to that used in previous examples. The method buildDockingPort() retrieves a DefaultDockingPort from createDockingPort() and adds a DockablePanel into it.
As shown here, the inner class ComponentProvider is used as the SubComponentProvider for the DefaultDockingPort. This inner class extends the ComponentProviderAdapter class, since only the createChildPort() and createSplitPane() methods are needed for this example. We also see references to our two other classes, DockablePanel and DemoBorderManager. DockablePanel has a getDockable() method that returns a Dockable instance responsible for delegation of its Dockable functionality. What is curiously absent here is the usual call to DockingManager.registerDockable(). Turning to DockablePanel.java, one finds that Dockable registration happens directly within the constructor. DockablePanel uses an inner class DockableImpl to handle its docking-related functionality. This is the object returned by getDockable(), and it is the object that is registered with the DockingManager at the end fo the DockablePanel constructor.
The DockablePanel is merely a generic JPanel with a TitledBorder, a BorderLayout, and a gray sidebar in the EAST region to act as a drag initiator. By itself, this is nothing we haven't seen before. The DemoBorderManager class is where the real substance of the example resides. It is designed specifically to work with the DockablePanel class, so its implementation is by no means generic. The private method getDesiredBorder() is responsible for creating a border for docked components.
This method is able to pull out the description of a DockablePanel, if one exists, and return a TitledBorder. Otherwise, it returns a dummy TitledBorder without a caption. The managePortNullChild() method merely assigns the dummy border to the entire DockingPort.
The managePortSimpleChild() method strips any border from the docked component and assigns the desired TitledBorder, complete with descriptive text, to the entire DockingPort.
The managePortTabbedChild() method removes the border from the DockingPort itself and assigns a desired border to each Component within the docked JTabbedPane. Because of the way getDesiredBorder() works, each TitledBorder in the JTabbedPane will match the current tab title.
The managePortSplitChild() method removes borders from the DockingPort, JSplitPane, and child DockingPorts. It then adds a desired border to each docked component in the split pane configuration.
|
||||||||||||||
|
|
||||||||||||||
|