![]() |
||
|
Eleritec Docking Framework Tutorial
|
||
|
||
|
Working with the JSplitPane
As with the tabbed pane, the JSplitPane used for splitting the layout of the DefaultDockingPort may be customized. The JSplitPane is created when a Component is docked in the NORTH, SOUTH, EAST,
or WEST regions of the DefaultDockingPort. Orientation of the JSplitPane is handled by the DefaultDockingPort based on the current docking region and therefore cannot be customized within a SubComponentProvider instance. Other other attributes of the JSplitPane, however, may be customized by a SubComponentProvider.
SplitPaneDemo.java is derived from CompoundDemo.java and, like TabbedPaneDemo.java, it contains a static inner class named ComponentProvider that implements the SubComponentProvider interface. In this case, however, createChildPort(), createSplitPane(), and getInitialDividerLocation() are properly implemented and createTabbedPane() returns a null reference. In this demo, we replace the default JSplitPane with its heavy border and bulky divider in favor of a cleaner looking implementation.
The createSplitPane() method is analogous to the createTabbedPane() method in that, by assigning a custom SubComponentProvider to the DefaultDockingPort that properly implements this method, the creation of the JSplitPane itself has been delegated to the custom class. The getInitialDividerLocation() is a convenience method that allows one to specify the initial proportional divider location of the JSplitPane as a percentage of the vertical or horizontal dimensions of the enclosing DefaultDockingPort. The value returned may fall between 0.0 and 1.0. By default, the DefaultDockingPort uses a value of 0.5 to divide the split pane in half. If getInitialDividerLocation() returns a value that exceeds the bounds of 0.0 to 1.0, the default behavior takes over and a value of 0.5 is assumed. The reason for separating getInitialDividerLocation() from createSplitPane() has to do with component validation, an in-depth explanation of which is outside the scope of this tutorial. However, it is simple enough to explain that in createSplitPane(), when the JSplitPane has first been created, its has yet to be added to and layed out by a parent Container, so its dimensions are (0, 0). Taking a proportional value of these dimension will yield zero, and so any call to setDividerLocation() on the JSplitPane within createSplitPane() would be rendered meaningless. Thus, the call to getInitialDividerLocation() on the assigned SubComponentProvider happens separately and later in the docking process than createSplitPane(). |
||
|
|
||
|