Dockable Interface

The Dockable interface is required to be implemented by any component that will be dockable.

Typically, this interface is implemented by a class that extends from JPanel.

The Dockable interface has a minimum subset of methods that must be implemented by the application and a set of methods that are optional. These optional methods provide extra customization points for the application per dockable.

Warning

The return values for the Dockable interface methods should be constant after the creation of the dockable component. Certain methods can be dynamic and the framework provides methods to update their values within the framework. Any method that doesn’t specify such a method can lead to unexpected behavior if changed after the dockable component is created.

Generally, if you wish to modify the return values after creating the dockable component, do so while the dockable is not docked. This can be checked with Docking.isDocked.

Mandatory Methods

These two methods do not provide default implementations in the interface and must be implemented by the application.

Persistent ID

String persistentID()

Provides a unique ID for the dockable to use within Modern Docking

Tab Text

String getTabText()

Provides the text that will be displayed on a tab when the dockable is in a JTabbedPane.

Important

If the text displayed on the tab ever changes, the application must call Docking.updateTabText with the dockables persistentID to force the framework to update the text. This should be done anytime the text is changed, just in case the dockable is displaying in a JTabbedPane. Undocking and docking the dockable again will also update the tab text.

Optional Methods

The following methods are provided to the application with a default. This means the application only needs to implement the methods if it wishes to change the default.

Type

int getType()
Default:

0

Provides an int to Modern Docking. This represents a unique type category for the dockable. Modern Docking will use this value when docking to determine which dockables to dock to.

Title Text

String getTitleText()
Default:

value of getTabText

Provides the text that Modern Docking should display on the header. This string can be different than getTabText

Tab Tooltip

String getTabTooltip()
Default:

null

Used by the framework to get the text to display as a tooltip on JTabbedPane tabs.

Icon

Icon getIcon()
Default:

null

Used by the framework to get the icon for the dockable to use in a JTabbedPane tab.

Is Floating Allowed

boolean isFloatingAllowed()
Default:

true

Tells Modern Docking if the dockable is allowed to be opened in its own window

Is Limited to Window

boolean isLimitedToWindow()
Default:

false

Allows the application to limit the dockable to the window it was initially docked in.

Style

DockableStyle getStyle()
Default:

DockableStyle.BOTH

The docking style of the dockable which can be DockableStyle.VERTICAL, DockableStyle.HORIZONTAL, DockableStyle.BOTH or DockableStyle.CENTER_ONLY. Modern Docking will use this to determine which docking regions to allow when docking this dockable. Docking handles that do not match this style will be hidden.

Auto Hide Style

DockableStyle getAutoHideStyle()
Default:

DockableStyle.BOTH

Determines which toolbars this dockable can be displayed on. Uses the same values as getStyle. DockableStyle.VERTICAL will allow the dockable on the east and west auto hide toolbars. DockableStyle.HORIZONTAL will allow the dockable on the south auto hide toolbar. DockableStyle.CENTER_ONLY is invalid for this method.

Closable

boolean isClosable()
Default:

true

Indicates to the docking framework whether the Dockable component can be closed and undocked.

Request Close

boolean requestClose()
Default:

true

Called by Modern Docking when the dockable is in the process of closing due to undock. This allows the application to stop the dockable from closing. For example, maybe the user has unsaved changes and the application wishes to confirm closing of the dockable.

Auto Hide Allowed

boolean isAutoHideAllowed()
Default:

false

Determines if the dockable can be set to the auto hide toolbars.

Min Max Allowed

boolean isMinMaxAllowed()
Default:

false

Determines if the dockable can be maximized so that it takes up all the space in the window.

Wrappable in Scrollpane

boolean isWrappableInScrollpane()
Default:

false

Allows the application to specify whether the docking framework should automatically wrap the Dockable component in a JScrollPane.

Has More Options

boolean getHasMoreOptions()
Default:

false

Flag that tells Modern Docking that this dockable has more menu items it wishes to add to the context menu. If this method returns true then Modern Docking will call addMoreOptions

Tab Preference

DockableTabPreference getTabPreference()
Default:

DockableTabPreference.NONE

Gives the dockables preferred tab location when in a JTabbedPane

Add More Options

void addMoreOptions(JPopupMenu menu)

Adds this dockables menu items to the context menu

Create Header UI

DockingHeaderUI createHeaderUI(HeaderController headerController, HeaderModel headerModel)
Default:

DockingInternal.createDefaultHeaderUI(headerController, headerModel)

Creates the header UI for this dockable. The default implementation will create the default Modern Docking header.

Update Properties

void updateProperties()

Modern Docking will call this method after setting the values of any fields annotated with DockingProperty. If there are no fields with that annotation then this method is not called