I have some controls in columns that I would like to look like this, and there is one row that is an exception:
+----+------------------+----+--------------------+
| X1 | Y1 | X5 | Y5 |
+----+------------------+----+--------------------+
| X2 | Y2 | X6 | Y6 |
+----+------------------+----+--------------------+
| X3 | Y3 | X7 | Y7 |
+----+-----+------------+----+--------------------+
| Special1 | Special 2 with long description |
+----+-----+------------+----+--------------------+
| X4 | Y4 | X8 | Y8 |
+----+------------------+----+--------------------+
and I was wondering how to do it with MigLayout. I am using Swing JavaBuilders with its condensed YAML syntax:
X1 Y1 X5 Y5
X2 Y2 X6 Y6
X3 Y3 X7 Y7
Special1 Special2
X4 Y4 X8 Y8
What I basically would like to do is make one row (the Special1/Special2) an exception, but I'm not sure how to do it (the above YAML fragment is not right).
this should do it:
public static void main(String[] args)
{
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 250));
Container cp = frame.getContentPane();
cp.setLayout(new MigLayout("fill, debug"));
String wrap = "wrap,";
String span2 = "spanx 2,";
String span3 = "spanx 3,";
cp.add(new JLabel("X1"));
cp.add(new JLabel("Y1"), span2);
cp.add(new JLabel("X5"));
cp.add(new JLabel("Y5"), wrap);
cp.add(new JLabel("X2"));
cp.add(new JLabel("Y2"), span2);
cp.add(new JLabel("X6"));
cp.add(new JLabel("Y6"), wrap);
cp.add(new JLabel("X3"));
cp.add(new JLabel("Y3"), span2);
cp.add(new JLabel("X7"));
cp.add(new JLabel("Y7"), wrap);
cp.add(new JLabel("Special 1"), span2);
cp.add(new JLabel("Special 2 with long description"), span3 + wrap);
cp.add(new JLabel("X4"));
cp.add(new JLabel("Y4"), span2);
cp.add(new JLabel("X7"));
cp.add(new JLabel("Y8"));
frame.pack();
frame.setVisible(true);
}
enjoy.