MigLayout is a Layout Manager for Swing and SWT created to replace all current layout managers and introduces a very easy to understand yet powerful syntax that resembles CSS.

This is the first posting in a series that will introduce MigLayout and show how easy it is to use.

If you want to start using MigLayout, just head over to www.miglayout.com and everything is there for you, indluding more examples. Miglayout is 100% free and Open Source (BSD).

The simplest mode of operation is the default grid-like layout. Every component added to the container ends up in the next cell, which by default is to the right. When you want to wrap to the next line just add a "wrap" and the next component will be on the next line. A lot can be configured and tweaked but for the most part it just works.

For instance the code below produces the panels in the screen shots. Note that the white spacing is larger on OS X, just as is recommended by the OS X style guide. You don't have to think about this, MigLayout does that for you.

`JPanel panel = new JPanel(new MigLayout()); panel.add(new JLabel("First Name")); panel.add(new JTextField(15)); panel.add(new JLabel("Surname"), "gap unrelated"); // Unrelated size is resolved per platform. panel.add(new JTextField(15), "wrap"); // Wraps to the next row in the grid. panel.add(new JLabel("Address")); panel.add(new JTextField(), "span, growx"); // Spans the rest of the cells in the row // and grows to fit that space.`