Question

I am trying to create a layout that will looking like:

+---+--------+---+
|   |        |   |
|   |        |   |
+---+        +---+
|   |        |   |
|   |        |   |
+---+--------+---+

Central cell should be twice as wide as other. I am trying achieve this with such code:

    val panel = new JPanel(new MigLayout("debug", "grow","grow" ))
    panel.add(new JPanel)
    panel.add(new JPanel, "span 2 2")
    panel.add(new JPanel, "wrap")
    panel.add(new JPanel)
    panel.add(new JPanel)

But as result all my cells have same width:

+----+----+----+
|    |    |    |
|    |    |    |
+----+    +----+
|    |    |    |
|    |    |    |
+----+----+----+

What I do wrong? I am using Scala but I don't think that problem is herein.

UPDATE Maybe someone can explain why this didn't work. Even if i try reproduce example from QuickStart guide it didn't work :

alt text

My code:

    val panel = new JPanel(new MigLayout("debug", "grow","grow" ))
    wrapTab.add(new JPanel)
    wrapTab.add(new JPanel, "span 2 2")
    wrapTab.add(new JPanel, "wrap")
    wrapTab.add(new JPanel)
    wrapTab.add(new JPanel, "wrap")
    wrapTab.add(new JPanel)
    wrapTab.add(new JPanel)

And as result all cols has equal size.

Was it helpful?

Solution

val panel = new JPanel(new MigLayout("debug", 
              "[grow 25][grow 50][grow 25]","grow" ))
panel.add(new JPanel)
panel.add(new JPanel, "spany 2")
panel.add(new JPanel, "wrap")
panel.add(new JPanel)
panel.add(new JPanel)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top