You can create some "CGridArea"s, which are just SplitDockStations, and drop them into the layout. You need to subclass them and override “isStackable” to allow them being in the same stack (otherwise some exceptions are thrown when you try to build the layout). The framework will never remove these stations automatically. Also the user cannot remove them or add new ones, which might be frustrating for some users…
You might also be interested in the CWorkingArea, which is a subclass of CGridArea. If any dockable is dropped on the CWorkingArea it cannot be dragged outside. Its behavior is like the panel on Eclipse where all the editors (the source file views) open.
(Btw.: I noticed an exception when grabbing a tab, exept an update in the next few days)
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.CGridArea;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.SingleCDockable;
import bibliothek.gui.dock.common.mode.ExtendedMode;
public class Dock8 {
private static class StackableCGridArea extends CGridArea{
public StackableCGridArea( CControl control, String id ){
super( control, id );
}
@Override
public boolean isStackable(){
return true;
}
}
public static CGridArea createGridArea( String id, CControl control ){
CGridArea area = new StackableCGridArea( control, id );
area.setTitleShown( true );
area.setTitleText( id );
control.add( area );
control.add( area, true );
return area;
}
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.setDefaultLocation(ExtendedMode.MINIMIZED, CLocation.base().minimalEast());
dockable.setDefaultLocation(ExtendedMode.EXTERNALIZED, CLocation.external( 0, 0, 300, 300 ));
return dockable;
}
public static void main( String[] args ){
SwingUtilities.invokeLater( new Runnable() {
public void run(){
JFrame frame = new JFrame( "Demo" );
CControl control = new CControl( frame );
frame.add( control.getContentArea(), BorderLayout.CENTER );
CGridArea gridArea1 = createGridArea( "grid 1", control );
CGridArea gridArea2 = createGridArea( "grid 2", control );
CGrid grid = new CGrid( control );
grid.add( 0, 0, 1, 2, gridArea1, gridArea2 );
grid.add( 1, 0, 1, 1, createDockable( "Green", Color.GREEN ) );
grid.add( 1, 1, 1, 1, createDockable( "Blue", Color.BLUE ) );
control.getContentArea().deploy( grid );
CGrid grid1 = new CGrid( control );
grid1.add( 0, 0, 1, 1, createDockable( "Red", Color.RED ) );
grid1.add( 0, 1, 1, 1, createDockable( "Yellow", Color.YELLOW ) );
gridArea1.deploy( grid1 );
CGrid grid2 = new CGrid( control );
grid2.add( 0, 0, 1, 1, createDockable( "Cyan", Color.CYAN ) );
grid2.add( 0, 1, 1, 1, createDockable( "Magenta", Color.MAGENTA ) );
gridArea2.deploy( grid2 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setBounds( 20, 20, 400, 400 );
frame.setVisible( true );
}
});
}
}