Please help me!
I’ve spent a lot of time trying to stack several DefaultSingleCDockable in the center of a CGridArea. When I deploy the grid, I get an error:
java.lang.ClassCastException: bibliothek.gui.dock.common.location.CStackLocation cannot be cast to bibliothek.gui.dock.common.location.CBaseLocation
I’m not sure how to proceed.
I have built an example that illustrates my problem:
public class ExampleFrame extends javax.swing.JFrame {
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ExampleFrame inst = new ExampleFrame();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public ExampleFrame() {
super();
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
CControl control = new CControl(this);
CGridArea gridArea = control.createGridArea("grid");
CGrid grid = new CGrid();
JPanel panelA = new JPanel();
panelA.setBackground(Color.BLUE);
JPanel panelB = new JPanel();
panelB.setBackground(Color.RED);
JPanel panelC = new JPanel();
panelC.setBackground(Color.YELLOW);
DefaultSingleCDockable dockableA = new DefaultSingleCDockable("panelA");
dockableA.getContentPane().add(panelA);
dockableA.setLocation(CLocation.base());
DefaultSingleCDockable dockableB = new DefaultSingleCDockable("panelB");
dockableB.getContentPane().add(panelB);
DefaultSingleCDockable dockableC = new DefaultSingleCDockable("panelC");
dockableC.getContentPane().add(panelC);
// Trying to stack the dockableB with the dockableA
CStackLocation stackLocationB = CLocation.base().normalNorth(1).stack();
dockableB.setLocation(stackLocationB);
// Trying to stack the dockableB with the dockableA
CStackLocation stackLocationC = CLocation.base().normalNorth(1).stack();
dockableC.setLocation(stackLocationC);
grid.add(0d, 0d, 1d, 1d, dockableA, dockableB, dockableC);
gridArea.deploy(grid);
this.add(gridArea.getComponent(), BorderLayout.CENTER);
pack();
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
}
}
}
When I remove the dockableC, I see the dockableA and dockableB stacked correctly.
How can I stack N components in the center of a CGridArea? I’m I using the grid correctly? I think I’m missing soemthing on how to build the correct CLocation for the N dockables I want to stack…
All I need is all DefaultSingleCDockable stacked using all space available in the middle of the CGridArea (possibly with other DefaultSingleCDockable around).
Thank you very much for spending the time to read my post and also thanks in advance for any clues you may have!