« prev next »
Java Docking Home> Developer Guide> How to Use Leaf Docks

How to Use Leaf Docks

:: Leaf Dock ::

A LeafDock is a Dock that contains Dockable objects.

:: Single Dock ::

The most simple leaf dock is a SingleDock. This type of dock can contain 0 or one dockables. When the dock has already a dockable, no other dockable can be docked in this dock anymore.

In the folowing example the single dock is created and the dockable is added:

		// Create the single docks.
		SingleDock leftDock = new SingleDock();
		SingleDock rightDock = new SingleDock();

		// Add the dockable to the dock.
		leftDock.addDockable(dockable1, new Position(0));
The dockable can be dragged from the left dock to the right and back.

:: Tab Dock ::

The most useful leaf dock is the TabDock. This dock can contain multiple dockables. There is tab for every dockable.

In the folowing example 2 tab docks are created and the dockables are added to the left tab dock:

		// Create the tab docks.
		TabDock leftDock = new TabDock();
		TabDock rightDock = new TabDock();

		// Add the dockables to the left tab dock.
		leftDock.addDockable(dockable1, new Position(0));
		leftDock.addDockable(dockable2, new Position(1));
The dockables can be dragged to the other dock. They can be dragged alone or together. The tabs can also be moved in the same tab dock.

:: Line Dock ::

A special leaf dock that organizes its dockables in a line, is a LineDock.

In the folowing example 2 line docks are created:

		// Create the line docks.
		LineDock topDock = new LineDock();
		LineDock bottomDock = new LineDock();

		// Add the dockables to these line docks.
		topDock.addDockable(dockable1, new Position(0));
		topDock.addDockable(dockable2, new Position(1));
		topDock.addDockable(dockable3, new Position(2));
		bottomDock.addDockable(dockable4, new Position(0));
		bottomDock.addDockable(dockable5, new Position(1));
		bottomDock.addDockable(dockable6, new Position(2));

:: Grid Dock ::

Another special leaf dock that organizes its dockables in a grid, is a GridDock.

In the folowing example 1 grid dock is created:

		// Create the grid dock.
		GridDock dock = new GridDock();

		// Add the dockables to the grid dock.
		dock.addDockable(dockable1, new Position(0));
		dock.addDockable(dockable2, new Position(1));
		dock.addDockable(dockable3, new Position(2));
		dock.addDockable(dockable4, new Position(3));
		dock.addDockable(dockable5, new Position(4));
		dock.addDockable(dockable6, new Position(5));

The source code of the samples can be found in:

SingleDocksShows the use of single docks.
TabDocksShows the use of tab docks.
LineDocksShows the use of line docks.
GridDocksShows the use of grid docks.

« prev next »