CWorkingArea

How can i do layout for a working area using CGrid?

Following code produce this exception:

Exception in thread "main" bibliothek.gui.dock.station.split.SplitDropTreeException: DockAcceptance does not allow to combine bibliothek.gui.dock.common.intern.DefaultCommonDockable@27e353 and bibliothek.gui.dock.common.intern.DefaultCommonDockable@bd928a
        at bibliothek.gui.dock.station.split.SplitNode.create(Unknown Source)
        at bibliothek.gui.dock.station.split.Root.evolve(Unknown Source)
        at bibliothek.gui.dock.SplitDockStation.dropTree(Unknown Source)
        at bibliothek.gui.dock.SplitDockStation.dropTree(Unknown Source)
        at bibliothek.gui.dock.common.CWorkingArea.deploy(Unknown Source)

JFrame frame = new JFrame("Demo");

        CControl control = new CControl(frame);


        frame.setLayout(new BorderLayout());

        frame.add(control.getContentArea(), BorderLayout.CENTER);

        CWorkingArea workingArea = control.createWorkingArea("working area");

        SingleCDockable dockable1 = createDockable("InWorkingArea", Color.GREEN);

        SingleCDockable dockable2 = createDockable("InWorkingArea2", Color.GREEN);

        CGrid grid = new CGrid();
        grid.add(0, 0, 1, 1, workingArea);

        control.getContentArea().deploy(grid);

        CGrid grid2 = new CGrid();
        grid2.add(0, 0, 1, 1, dockable1, dockable2);
        workingArea.deploy(grid2);
        frame.setVisible(true);

Thanks in advance!

Uh, that is a bug in the framework. For now use the workaround with the method “setWorkingArea” (like in the code below). I’ll repair this in the next version.


        CControl control = new CControl(frame);


        frame.setLayout(new BorderLayout());

        frame.add(control.getContentArea(), BorderLayout.CENTER);

        CWorkingArea workingArea = control.createWorkingArea("working area");

        SingleCDockable dockable1 = createDockable("InWorkingArea", Color.GREEN);

        SingleCDockable dockable2 = createDockable("InWorkingArea2", Color.GREEN);

        // **************************************
        dockable1.setWorkingArea( workingArea );
        dockable2.setWorkingArea( workingArea );
        // **************************************
        
        CGrid grid = new CGrid();
        grid.add(0, 0, 1, 1, workingArea);

        control.getContentArea().deploy(grid);

        CGrid grid2 = new CGrid();
        grid2.add(0, 0, 1, 1, dockable1, dockable2);
        workingArea.deploy(grid2);
        frame.setVisible(true);```

It made the layout, but default actions like close, maximize, minimize have gone

The answer to the other question (why is the close-button missing) was:

	dockable1.setWorkingArea( workingArea );
	dockable2.setWorkingArea( workingArea );
	control.add( dockable1 );
	control.add( dockable2 );
	// **************************************```

Alternativ:CGrid grid2 = new CGrid(control);

I realized that i did not add the dockables to the controller and therefore deleted the message:) Thanks anyway