Stacking

Hi,

I’m trying to get some dockables to stack programmatically, but without much luck. I’ve tried:

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");
    workingArea.setLocation(CLocation.base().normalRectangle(0, 0, 1, 1));
    workingArea.setVisible(true);

    SingleCDockable left = createDockable("Left", Color.GREEN, control);
    left.setLocation(CLocation.base().normalWest(.25));
    control.add(left);
    left.setVisible(true);

    SingleCDockable leftBottom = createDockable("Left2", Color.GREEN, control);
    leftBottom.setLocation(CLocation.base().normalWest(.25));
    control.add(leftBottom);
    leftBottom.setVisible(true);

That just puts Left2 to the west of Left. I’ve also tried setting Left2’s location to what’s returned from Left, but that results in the same thing. Note that I if I call setVisible on Left and then getBaseLocation() that returns null.

What’s the correct way to get dockables to stack?

thanks,

Nick

The problems is, that the size of any Component is 0/0. That seems to yield some negative sizes internally because some elements (like the space between two CDockable) have fixed size. And these negative sizes then mess up with the algorithm that decides who to insert your new CDockable.

Hm, it seems to work if the JFrame is already visible.

Well it is a bug, I’ll try to repair it for the next release. Until then I suggest using a CGrid:

        CControl control = new CControl(frame);
     
        frame.setLayout(new BorderLayout());
        frame.add(control.getContentArea(), BorderLayout.CENTER);
       
        CWorkingArea workingArea = control.createWorkingArea("working area");
        
        SingleCDockable left = createDockable("Left", Color.GREEN );
        left.setLocation(CLocation.base().normalWest(.25));
        
        SingleCDockable leftBottom = createDockable("Left2", Color.GREEN );
        leftBottom.setLocation(CLocation.base().normalWest(.25));

        CGrid grid = new CGrid();
        grid.add( 0.25, 0, 0.75, 1, workingArea );
        grid.add( 0, 0, 0.25, 1, left, leftBottom );
        control.getContentArea().deploy( grid );```

[**Edit**: uh, that bugfix was not hard. I think I put up a preview version of 1.0.6 within the next hour so you can use the fix]

Re. putting up a preview of 1.0.6, that would be really useful. Using a grid would lead to an overly complicated work-around for me.

thanks,

nick

Ok, you might try it. Please tell me whether it works now.

Information about 1.0.6
Download Preview 1.0.6