Layout and position

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.

something like this:

±–±------------+
| | |
±–+ |
| | |
±–±------------+
| | |
±–±------------+

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);

    SingleCDockable dock3 = createBackup("Test 4");
    control.add(dock3);
    dock.setVisible(true);
    grid.add(1, 0, 5, 1, dock3);
    
    
    SingleCDockable dock1 = createBackup("Test 2");
    control.add(dock1);
    dock.setVisible(true);
    grid.add(0, 1, 1, 1, dock1);

    SingleCDockable dock2 = createBackup("Test 3");
    control.add(dock2);
    dock.setVisible(true);
    grid.add(0, 2, 1, 1, dock2);

   
    CContentArea conte = control.getContentArea();
    conte.deploy(grid);

Thanks for any help.

Harringf

Sorry… The 3 dockables should be on the LEFT hand side and the 2 other dockables should be on the RIGHT hand side.

Harringf

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;
    }
}

Beni, THANK YOU SO MUCH.

I was trying to do it with Perspectives and CGrid.

Again, thank you so much for your reply.

Harring