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

public class MainPanel extends JPanel{
    public MainPanel() {
        super(new BorderLayout());
        Color pbc = UIManager.getColor("Panel.background");
        Box box1 = Box.createVerticalBox();
        box1.setBorder(makeTitledSeparator("TitledBorder", pbc, pbc.darker(), pbc.brighter(), 2, TitledBorder.DEFAULT_POSITION));
        box1.add(new JCheckBox("JCheckBox 0"));
        box1.add(new JCheckBox("JCheckBox 1"));

        Color c = new Color(100,180,200);
        Box box2 = Box.createVerticalBox();
        box2.setBorder(makeTitledSeparator("TitledBorder ABOVE TOP", pbc, c.darker(), c.brighter(), 2, TitledBorder.ABOVE_TOP));
        box2.add(new JCheckBox("JCheckBox 2"));
        box2.add(new JCheckBox("JCheckBox 3"));

        Box box3 = Box.createVerticalBox();
        box3.add(new JSeparator());
        box3.add(new JCheckBox("JCheckBox 4"));
        box3.add(new JCheckBox("JCheckBox 5"));

        JPanel p = new JPanel(new GridLayout(0, 1));
        p.add(box1);
        p.add(box2);
        p.add(box3);

        add(p, BorderLayout.NORTH);
        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        setPreferredSize(new Dimension(320, 240));
    }
    private static Border makeTitledSeparator(String title, final Color color, final Color darker, final Color brighter, final int height, int titlePosition) {
        return BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(height, 0, 0, 0, new Icon() {
            private int width = -1;
            private Paint painter1, painter2;
            @Override public void paintIcon(Component c, Graphics g, int x, int y) {
                int w = c.getWidth();
                if(w!=width || painter1==null || painter2==null) {
                    width = w;
                    Point2D start  = new Point2D.Float(0f, 0f);
                    Point2D end    = new Point2D.Float((float)width, 0f);
                    float[] dist   = {0.0f, 1.0f};
                    painter1 = new LinearGradientPaint(start, end, dist, new Color[] {darker,   color});
                    painter2 = new LinearGradientPaint(start, end, dist, new Color[] {brighter, color});
                }
                int h = getIconHeight()/2;
                Graphics2D g2  = (Graphics2D)g.create();
                g2.setPaint(painter1);
                g2.fillRect(x, y,   width, getIconHeight());
                g2.setPaint(painter2);
                g2.fillRect(x, y+h, width, getIconHeight()-h);
                g2.dispose();
            }
            @Override public int getIconWidth()  { return 200; } //dummy width
            @Override public int getIconHeight() { return height; }
        }), title, TitledBorder.DEFAULT_JUSTIFICATION, titlePosition);
    }

    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(Exception e) {
            e.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

@@ -373,17 +373,16 @@
  Box box
-1
  = Box.c
@@ -416,19 +416,12 @@
  box
-1.setBorder
+.add
 (mak
@@ -527,33 +527,32 @@
 N));%0A        box
-1
 .add(new JCheckB
@@ -582,17 +582,16 @@
      box
-1
 .add(new
@@ -613,24 +613,70 @@
 eckBox 1%22));
+%0A        box.add(Box.createVerticalStrut(10));
 %0A%0A        Co
@@ -719,66 +719,15 @@
     
-Box box2 = Box.createVerticalBox();%0A        box2.setBorder
+box.add
 (mak
@@ -832,33 +832,32 @@
 P));%0A        box
-2
 .add(new JCheckB
@@ -887,17 +887,16 @@
      box
-2
 .add(new
@@ -923,25 +923,24 @@
 x 3%22));%0A
-%0A
         
 Box box3
@@ -935,19 +935,16 @@
     
-Box box3 = 
+box.add(
 Box.
@@ -949,39 +949,45 @@
 x.createVertical
-Box(
+Strut(10)
 );%0A
+%0A
         box3.add
@@ -973,33 +973,32 @@
 ));%0A%0A        box
-3
 .add(new JSepara
@@ -1008,33 +1008,32 @@
 ());%0A        box
-3
 .add(new JCheckB
@@ -1063,17 +1063,16 @@
      box
-3
 .add(new
@@ -1099,25 +1099,24 @@
 x 5%22));%0A
-%0A
         
 JPanel p
@@ -1111,73 +1111,47 @@
     
-JPanel p = new JPanel(new GridLayout(0, 1));%0A        p.add(box1);
+//box.add(Box.createVerticalStrut(8));%0A
 %0A   
@@ -1159,56 +1159,15 @@
     
-p.
 add(box
-2);%0A        p.add(box3);%0A%0A        add(p
 , Bo
@@ -1322,22 +1322,26 @@
  static 
-Border
+JComponent
  makeTit
@@ -1475,23 +1475,270 @@
         
-return 
+JLabel l = new JLabel() %7B%0A            @Override public Dimension getMaximumSize() %7B%0A                Dimension d = super.getPreferredSize();%0A                d.width = Short.MAX_VALUE;%0A                return d;%0A            %7D%0A        %7D;%0A        l.setBorder(
 BorderFa
@@ -3106,24 +3106,43 @@
 osition)
+);%0A        return l
 ;%0A    %7D%0A
 %0A    pub
@@ -3133,17 +3133,16 @@
 ;%0A    %7D%0A
-%0A
     publ

Change layout