![]() |
|||
|
Eleritec Docking Framework Tutorial
|
|||
|
|||
|
Working with the JTabbedPane
When more than one Component has been docked within a DefaultDockingPort's CENTER region, the DefaultDockingPort places each Component within a JTabbedPane and sets the new tabbed container as its currently docked component. Thus, a call to getDockedComponent() on the DefaultDockingPort will return a reference to this JTabbedPane.
The DefaultDockingPort will, by default, create a JTabbedPane with the zero-argument constructor. In order to override this behavior, one must implement a SubComponentProvider with a customized
createTabbedPane() method. In TabbedPaneDemo.java we have just such an example. Again, this example is derived from CompoundDemo.java with several modifications.
This demo uses a static inner class called ComponentProvider to implement the SubComponentProvider interface. When each DefaultDockingPort is created, a ComponentProvider instance is plugged in via setComponentProvider(). And the constructor for each ComponentProvider takes in an int argument, assigning it to an instance variable named tabPosition. This code is shown as follows:
As shown in TabbedPaneDemo.java, the description sent to each DefaultDockingPort is used to determine a corresponding tab position for use with a JTabbedPane, and each ComponentProvider keeps track of this value. When a Dockable is docked into the center area of a DefaultDockingPort and a JTabbedPane is required, the assigned SubComponentProvider's createTabbedPane() method is invoked.
The ComponentProvider customizes the tab position for each DefaultDockingPort based on its region within the underlying BorderLayout as determined in getTabPosition(). In this fashion, one has the option to customize any feature desired on the JTabbedPane before it is returned to the DefaultDockingPort. In this example, only the tab position has been customized. In practice, JTabbedPane customization is limited to the developer's desires and imagination. It is important to note in this example that the non-tab related methods on the ComponentProvider all inherit from the ComponentProviderAdapter superclass, which returns null or nonsense values. When a split pane is required by the DefaultDockingPort, the DefaultDockingPort class is intelligent enough to recognize null or nonesense split pane values returned by our tab-specific code and resort to default behavior in these instances. This concept will work similarly for split-pane-specific code that returns junk values for the tabbed pane method. |
|||
|
|
|||
|