javaswinglayout-managermiglayout

Combine cells to MigLayout?


How to combine two cells using MigLayout?

I have two cells, as shown in the following code. I want to combine them, what do I have to do?

JPanel jPanelAccOil = new JPanel(new MigLayout("", "0[]0", "0[]0"));
jPanelAccOil.add(new JPanelInAI(null, "",
    sistema.getGestorComunicacioOPC().getParametresOPCHyperG().getActuatorOilPressure()));
this.add(jPanelAccOil, "cell 2 3");

JPanel jPanelAccPneumatic = new JPanel(new MigLayout("", "0[]0", "0[]0"));
jPanelAccPneumatic.add(new JPanelInAI(null, "",
    sistema.getGestorComunicacioOPC().getParametresOPCHyperG().getAccPneumaticPressure()));
this.add(jPanelAccPneumatic, "cell 3 3, wrap");

Solution

  • You can use to span cells:

    span 2 
    

    try this:

    JPanel jPanelAccPneumatic = new JPanel(new MigLayout("", "0[]0", "0[]0"));
    jPanelAccPneumatic.add(new JPanelInAI(null, "",
        sistema.getGestorComunicacioOPC().getParametresOPCHyperG().getAccPneumaticPressure()));
    this.add(jPanelAccPneumatic, "cell 3 3, span 2, wrap");