I am having a hard time positioning the dockables. I read both the core and the common docs (pdf) and I could not find a complete example. I also looked at notes and the tutorial. I copied some code from there,
but changing to the layout I want proves to be difficult.
I would like to have
3 dockables on the right hand side with 25 % width (all with same height)
2 dockables on the left hand side with 75% width ( top one with 70% hight, bottom with 30% height.
I have played with the following code to no avail.
CGrid grid = new CGrid(control);
SingleCDockable dock = createBackup(“Test 1”);
control.add(dock);
dock.setVisible(true);
grid.add(0, 0, 1, 1, dock);
Something like the code below? I used integers for simplicity, so the numbers do not add up exactly (3*33 != 100), but you could also insert doubles instead if you need it to be more exact.
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
public class Dock33 {
public static void main( String[] args ){
// setting up the frame...
JFrame frame = new JFrame();
frame.setBounds( 20, 20, 500, 500 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
final CControl control = new CControl( frame );
// grid will call "control.add" automatically because we use the
// constructor CGrid(CControl)
CGrid grid = new CGrid( control );
grid.add( 0, 0, 25, 33, create( "Red", Color.RED ) );
grid.add( 0, 33, 25, 33, create( "Green", Color.GREEN ) );
grid.add( 0, 66, 25, 33, create( "Blue", Color.BLUE ) );
grid.add( 25, 0, 75, 70, create( "White", Color.WHITE ) );
grid.add( 25, 70, 75, 30, create( "Black", Color.BLACK ) );
control.getContentArea().deploy( grid );
frame.add( control.getContentArea() );
frame.setVisible( true );
}
public static DefaultSingleCDockable create( final String title, Color color ){
JPanel panel = new JPanel();
panel.setOpaque(true);
panel.setBackground(color);
DefaultSingleCDockable singleDockable = new DefaultSingleCDockable(title, title, panel);
return singleDockable;
}
}