Help

How do I report bugs?

Just write a message in Byte-Welt. There is a Bug Tracker but we seldomly use it.



What do I need?

You need Java 1.5, you need to download DockingFrames and you need to include the jar-file(s) into your classpath.



How does this library work?

Have a look at the guide for the core library, the guide for the common project or at the online api documentation.
There is also a forum online: Byte-Welt (in former times german, now english)




How to write a small application?

Not much code is needed to write this application:

Have a look at the code, and later on the explanation of the code.

package test;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.gui.DockFrontend;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.station.split.SplitDockGrid;

public class Dock {
        public static void main( String[] args ){
                JFrame frame = new JFrame( "Demo" );
                DockFrontend frontend = new DockFrontend( frame );
                SplitDockStation station = new SplitDockStation();
                
                frame.add( station.getComponent() );
                frontend.addRoot( station, "station" );
                
                SplitDockGrid grid = new SplitDockGrid();
                grid.addDockable( 0, 0, 1, 1, createDockable( "Red", Color.RED ) );
                grid.addDockable( 0, 1, 1, 1, createDockable( "Green", Color.GREEN ) );
                grid.addDockable( 1, 0, 1, 1, createDockable( "Blue", Color.BLUE ) );
                grid.addDockable( 1, 1, 1, 1, createDockable( "Yellow", Color.YELLOW ) );
                station.dropTree( grid.toTree() );
                
                frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
                frame.setBounds( 20, 20, 400, 400 );
                frame.setVisible( true );
        }
        
        public static Dockable createDockable( String title, Color color ){
                JPanel panel = new JPanel();
                panel.setOpaque( true );
                panel.setBackground( color );
                return new DefaultDockable( panel, title );
        }
}

Now lets explain the code:

DockFrontend frontend = new DockFrontend( frame );
SplitDockStation station = new SplitDockStation();
Here a frontend is created. A frontend hides the more complex operations from the developer.
Also a station is created. A station is a container for visible panels.

frontend.addRoot( station, "station" );
Connect the root-station with the frontend.

SplitDockGrid grid = new SplitDockGrid();
grid.addDockable( 0, 0, 1, 1, createDockable( "Red", Color.RED ) );
grid.addDockable( 0, 1, 1, 1, createDockable( "Green", Color.GREEN ) );
grid.addDockable( 1, 0, 1, 1, createDockable( "Blue", Color.BLUE ) );
grid.addDockable( 1, 1, 1, 1, createDockable( "Yellow", Color.YELLOW ) );
station.dropTree( grid.toTree() );
Here we use a helper-class. First we create a layout containing four panels, then we transform the layout in a form which can be understood by the station. The panels could be dropped directly without the grid, but the result would not look so nice.

JPanel panel = new JPanel();
panel.setOpaque( true );
panel.setBackground( color );
return new DefaultDockable( panel, title );
Every panel that we want to show, must be wrapped into a "Dockable". The "DefaultDockable", which we use here, can be compared to a "JInternalFrame": it has a content-pane where we can add our stuff (or we can go directly through the constructor).



How to write a small application with common?

Common hides complexity whenever possible. Compare the available features on the application below to the features on the original application above. Much more can be done while the size of the code remains the same.

Have a look at the code, and later on the explanation of the code.

package test;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

import bibliothek.gui.dock.common.*;
import bibliothek.gui.dock.common.menu.SingleCDockableListMenuPiece;
import bibliothek.gui.dock.facile.menu.RootMenuPiece;

public class Dock {
        public static void main( String[] args ){
                JFrame frame = new JFrame( "Demo" );
                CControl control = new CControl( frame );
                
                frame.add( control.getContentArea() );
                
                CGrid grid = new CGrid( control );
                grid.add( 0, 0, 1, 1, createDockable( "Red", Color.RED ) );
                grid.add( 0, 1, 1, 1, createDockable( "Green", Color.GREEN ) );
                grid.add( 1, 0, 1, 1, createDockable( "Blue", Color.BLUE ) );
                grid.add( 1, 1, 1, 1, createDockable( "Yellow", Color.YELLOW ) );
                control.getContentArea().deploy( grid );
                
                SingleCDockable black = createDockable( "Black", Color.BLACK );
                control.add( black );
                black.setLocation( CLocation.base().minimalNorth() );
                black.setVisible( true );
                
                RootMenuPiece menu = new RootMenuPiece( "Colors", false );
                menu.add( new SingleCDockableListMenuPiece( control ));
                JMenuBar menuBar = new JMenuBar();
                menuBar.add( menu.getMenu() );
                frame.setJMenuBar( menuBar );
                
                frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
                frame.setBounds( 20, 20, 400, 400 );
                frame.setVisible( true );
        }
        
        public static SingleCDockable createDockable( String title, Color color ) {
                JPanel panel = new JPanel();
                panel.setOpaque( true );
                panel.setBackground( color );
                DefaultSingleCDockable dockable = new DefaultSingleCDockable( title, title, panel );
                dockable.setCloseable( true );
                return dockable;
        }
}

Now lets explain the code:

JFrame frame = new JFrame( "Demo" );
CControl control = new CControl( frame );

frame.add( control.getContentArea() );
Here a controller and a content area are created. The content area is a JComponent which has several "Dockables" as children. The controller manages all the elements of DockingFrames.

CGrid grid = new CGrid( control );
grid.add( 0, 0, 1, 1, createDockable( "Red", Color.RED ) );
grid.add( 0, 1, 1, 1, createDockable( "Green", Color.GREEN ) );
grid.add( 1, 0, 1, 1, createDockable( "Blue", Color.BLUE ) );
grid.add( 1, 1, 1, 1, createDockable( "Yellow", Color.YELLOW ) );
control.getContentArea().deploy( grid );
Here some "Dockables" are created and put into a grid. A grid just describes a layout, it does not become part of the dock-tree. Finally the content of the grid is used to put the "Dockables" onto the content area.

SingleCDockable black = createDockable( "Black", Color.BLACK );
control.add( black );
black.setLocation( CLocation.base().minimalNorth() );
black.setVisible( true );
It is possible to add single "Dockables" at any time. Each "Dockable" must be registered at a controller. The location is optional, a default location would be used if the location were not set. Eventually the "Dockable" is made visible.

RootMenuPiece menu = new RootMenuPiece( "Colors", false );
menu.add( new SingleCDockableListMenuPiece( control ));
JMenuBar menuBar = new JMenuBar();
menuBar.add( menu.getMenu() );
frame.setJMenuBar( menuBar );
The common-project contains some menus. These menus can be combined in a tree of "MenuPieces". Here only one piece is used, the "SingleCDockableListMenuPiece". It shows a "JCheckBoxMenuItem" for each "SingleCDockable" that is in the realm of the controller. With this menu, each "Dockable" can be made visible or invisible.