« prev next »
Java Docking Home> Developer Guide> How to Use the Component Factory

How to Use the Component Factory

:: Component Factory ::

The docking library uses a SwComponentFactory to create the components of the docks, windows, headers, borders, etc... The component factory can be found in the docking manager.

		SwComponentFactory componentFactory = DockingManager.getComponentFactory();
The default component factory, that the docking manager uses, is a DefaultSwComponentFactory. If you want to change the components that the library uses, you have to give your own component factory to the docking manager.

:: Decorated floating windows ::

The floating windows that the default component factory creates are undecorated.

If you want decorated windows, you have to create your own component factory like this:

	/**
	 * This component factory creates decorated dialogs for the floating windows.
	 * 
	 * @author Heidi Rakels.
	 */
	private class MyComponentFactory extends DefaultSwComponentFactory 
	{

		public JDialog createJDialog(Window owner)
		{
			// Create the dialog.
			JDialog dialog = null;
			if (owner instanceof JDialog)
			{
				dialog = new JDialog((JDialog)owner, ((JDialog)owner).getTitle());
			}
			else if (owner instanceof JFrame)
			{
				dialog =  new JDialog((JFrame)owner, ((JFrame)owner).getTitle());
			}
			else 
			{
				dialog = new JDialog((JFrame)null, "");
			}
			
			return dialog;
		}
		
	}
Give this component factory to the docking manager:
		// Give our component factory to the docking manager.
		DockingManager.setComponentFactory(new MyComponentFactory());

:: Split docks with small dividers ::

The default splits of a javax.swing.JSplitPane are quite big.

If you want smaller divider for the split docks, you have to create your own component factory like this:

	/**
	 * This component factory creates split panes with small dividers.
	 * 
	 * @author Heidi Rakels.
	 */
	private class MyComponentFactory extends DefaultSwComponentFactory 
	{

		public JSplitPane createJSplitPane()
		{
			
			JSplitPane splitPane = super.createJSplitPane();
			splitPane.setDividerSize(3);
			return splitPane;
		}

	}
Give this component factory to the docking manager:
		// Give our component factory to the docking manager.
		DockingManager.setComponentFactory(new MyComponentFactory());

:: Custom headers for the leaf docks and visualizers ::

The library uses a lot of headers. Leaf docks are using headers. Minimizers and maximizers are also using headers.

The header interfaces:

The headers of the leaf docks can be used for the following things:

You can provide your own headers in the library. The component factory is also responsible for creating the headers.

The default headers created by the default component factory are:



The source code of the samples can be found in:

DecoratedDialogsShows decorated floating windows.
SmallDividerSplitDocksShows split docks with small dividers.



« prev next »