MigLayout supports adding multiple components to a dock. I want to add multiple components to the west dock, from top to bottom. However, it seems as if MigLayout can only manage a horizontal layout inside a dock. I tried many parameters (e.g., wrap, growy, flowy) without success.
So, is there any possibility to wrap or set a vertical flow inside a dock? Or is this not possible with MigLayout itself, but only by using an extra sidepanel-component?
Here an example of the unwanted horizontal layout inside the west dock:
How to get the red, green, blue components below each other? Here is the code:
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
public class MigTest extends JFrame {
MigTest() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(800, 600);
setLayout(new MigLayout("fill"));
JTextField dockW1 = new JTextField("West 1"); dockW1.setBackground(Color.red);
JTextField dockW2 = new JTextField("West 2"); dockW2.setBackground(Color.green);
JTextField dockW3 = new JTextField("West 3"); dockW3.setBackground(Color.blue);
JTextField center = new JTextField("Center"); center.setBackground(Color.lightGray);
add(center, "grow");
// HOW TO LAYOUT THESE COMPONENTS VERTICALLY INSIDE WEST DOCK ?
add(dockW1, "dock west, wrap, growy, flowy");
add(dockW2, "dock west, wrap, growy, flowy");
add(dockW3, "dock west, wrap, growy, flowy");
setVisible(true);
}
public static void main(String[] args) {
new MigTest();
}
}
[edit]: Note that I do not want to put dockW1
, dockW2
,dockW3
, and center
into a single grid, since I plan to apply a complex layout in the center area, independently of the side-area, which is the reason why the docking feature was invented :)