package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import javax.swing.*;

public final class MainPanel extends JPanel {
    private static final int SIZE = 6;
    private MainPanel() {
        super(new BorderLayout());

        JPanel panel = new JPanel(new GridBagLayout());
        panel.setBorder(BorderFactory.createTitledBorder("Brick Layout"));
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.HORIZONTAL;
        //c.weightx = 1d; c.weighty = 0d;
        for (int i = 0; i < SIZE; i++) {
            int x = i & 1; //= (i % 2 == 0) ? 0 : 1;
            for (int j = 0; j < SIZE; j++) {
                c.gridy = i;
                c.gridx = 2 * j + x;
                c.gridwidth = 2;
                panel.add(new JButton(" "), c);
            }
        }
        //<blockquote cite="https://community.oracle.com/thread/1357310"
        //           title="GridBagLayout to create a board">
        //<dummy-row>
        c.gridwidth = 1;
        c.gridy = 10;
        for (c.gridx = 0; c.gridx <= 2 * SIZE; c.gridx++) {
            panel.add(Box.createHorizontalStrut(24), c);
        }
        //</dummy-row>
        //</blockquote>

        add(panel);
        setPreferredSize(new Dimension(320, 240));
    }
    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setMinimumSize(new Dimension(300, 120));
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

@@ -207,16 +207,17 @@
 nal int 
+X
 SIZE = 6
@@ -218,16 +218,96 @@
 ZE = 6;%0A
+    private static final int YSIZE = 8;%0A    private static final int WIDTH = 2;%0A
     priv
@@ -608,40 +608,45 @@
     
-//c.weightx = 1d; c.weighty = 0d
+c.gridy = GridBagConstraints.RELATIVE
 ;%0A  
@@ -664,26 +664,27 @@
 int 
-i
+y
  = 0; 
-i
+y
  %3C 
+Y
 SIZE; 
-i
+y
 ++) 
@@ -701,29 +701,102 @@
     
-int x = i
+////c.gridy = GridBagConstraints.RELATIVE; //c.gridy = y;%0A            //int d = y
  & 
+0b
 1; //= 
-(i
+y
  %25 2
@@ -800,17 +800,16 @@
 %25 2 == 0
-)
  ? 0 : 1
@@ -826,37 +826,20 @@
     
-for (int j = 0; j %3C SIZE; j++
+//if (d == 1
 ) %7B%0A
@@ -842,32 +842,34 @@
 ) %7B%0A            
+//
     c.gridy = i;
@@ -866,13 +866,17 @@
 grid
-y = i
+width = 1
 ;%0A  
@@ -877,32 +877,34 @@
  1;%0A            
+//
     c.gridx = 2 
@@ -905,23 +905,125 @@
 x = 
-2 * j + x;%0A    
+0;%0A            //    panel.add(new JButton(%22s%22), c);%0A            //%7D%0A            c.gridx = y & 0b1; //start x offset%0A
     
@@ -1044,19 +1044,69 @@
 width = 
-2
+WIDTH
 ;%0A
+            for (int x = 0; x %3C XSIZE; x++) %7B%0A
         
@@ -1149,33 +1149,53 @@
 c);%0A            
-%7D
+    c.gridx += WIDTH;
 %0A        %7D%0A     
@@ -1179,32 +1179,36 @@
  WIDTH;%0A        
+    
 %7D%0A        //%3Cblo
@@ -1205,81 +1205,122 @@
     
-//%3Cblockquote cite=%22https://community.oracle.com/thread/1357310%22%0A
+    //if (d == 0) %7B%0A            //    c.gridwidth = 1;%0A            //    panel.add(new JButton(%22e%22), c);%0A 
         
 //  
@@ -1319,18 +1319,23 @@
     
-//
+   //%7D%0A
         
    t
@@ -1334,18 +1334,20 @@
     
+%7D%0A
    
-title=%22
+     //
 Grid
@@ -1377,10 +1377,62 @@
 oard
-%22%3E
+%0A        //https://community.oracle.com/thread/1357310
 %0A   
@@ -1475,32 +1475,34 @@
 th = 1;%0A        
+//
 c.gridy = 10;%0A  
@@ -1495,18 +1495,44 @@
 gridy = 
-10
+GridBagConstraints.REMAINDER
 ;%0A      
@@ -1566,12 +1566,17 @@
  %3C= 
-2
+WIDTH
  * 
+X
 SIZE
@@ -1683,32 +1683,8 @@
 row%3E
-%0A        //%3C/blockquote%3E
 %0A%0A  

use GridBagConstraints.RELATIVE