Stacking dockables while initializing CGrid

Hello,
I just discovered this great framework so I’m still getting accustomed to using it. Before I get to my issue, first let me say that what I have used so far is just awesome! Great, great work. Thank you so much for sharing this with the world :).

So, I am using 1.0.8-preview2

The functionality to automatically stack dockables when adding to a CGrid (as documented in the Common 1.0.7 documentation, p.16) does not seem to work.

I am calling


DefaultSingleCDockable dock1 = create(...);
DefaultSingleCDockable dock2 = create(...);
CGrid grid = new CGrid(control);
grid.add(0, 0, 1, 1, dock1, dock2);

When I run it, I get the following exception

Exception in thread “AWT-EventQueue-0”
bibliothek.gui.dock.station.split.SplitDropTreeException: DockAcceptance does not allow to combine
bibliothek.gui.dock.common.intern.DefaultCommonDockable@15fadcf and
bibliothek.gui.dock.common.intern.DefaultCommonDockable@fbb7cbat bibliothek.gui.dock.station.split.SplitNode.create(SplitNode.java:478)
at bibliothek.gui.dock.station.split.Node.evolve(Node.java:392)
at bibliothek.gui.dock.station.split.SplitNode.create(SplitNode.java:530)
at bibliothek.gui.dock.station.split.Node.evolve(Node.java:386)
at bibliothek.gui.dock.station.split.SplitNode.create(SplitNode.java:530)
at bibliothek.gui.dock.station.split.Root.evolve(Root.java:162)
at bibliothek.gui.dock.SplitDockStation.dropTree(SplitDockStation.java:1549)
at bibliothek.gui.dock.SplitDockStation.dropTree(SplitDockStation.java:1518)
at bibliothek.gui.dock.common.CContentArea.deploy(CContentArea.java:198

I did manage to get around it by calling


DefaultSingleCDockable dock1 = create(...);
DefaultSingleCDockable dock2 = create(...);

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

control.add(dock2);
dock2.setLocation(dock1.getBaseLocation());
dock2.setVisible(true);

but I’d rather do it the clean way while setting up CGrid. Am I doing something wrong?

Uhm, that should work. Could you give me your whole application so I can try it out? [Edit: especially your “create” method could be interesting].

If I write something like you described, it works:


import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;

public class Dock {
	public static void main(String args[])
	{
		JFrame frame = new JFrame();
		CControl control = new CControl( frame );
	
		CGrid grid = new CGrid( control );
		frame.add( control.getContentArea() );
		
		DefaultSingleCDockable dock1 = new DefaultSingleCDockable( "a", "A" ); 
		DefaultSingleCDockable dock2 = new DefaultSingleCDockable( "b", "B" );
		grid.add( 0, 0, 1, 1, dock1, dock2 );
		control.getContentArea().deploy( grid );
		
		frame.setBounds(10, 30, 600, 400);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);		
	}
}```

Ahh you found my bug - it was my ‘create’ method. This is what I was doing:

  String panelName = celPanel.getName();
  DefaultSingleCDockable dockable = 
      new DefaultSingleCDockable(panelName, panelName, celPanel.getComponent());
  dockable.setStackable(false);
  return dockable;
}```
(CELPanel is specific to my app)

I was setting the dockable to not be stackable (which is what I want), but I just needed to set it after I deployed the grid. 

It is interesting that my workaround successfully stacks the two dockables even when isStackable is set to false on dock1. I guess it works differently than what the deploy() method does? Anyway, I'll just pull out line 5 and call it after I deploy the grid - thanks for the help :D

Yes the second method should have thrown that exception as well… but the check is just not called :twisted: