Well, I still haven’t really got around to doing much actually with Griffon, and we’ll still have to put that off until the next post – this time I want to show a little of the layout we chose to use.
I mentioned before that MigLayout looks to be the best way to go, so I set up a few trials (and errors, of course) and came up with a decent layout with which to start. It’s not the final version, there are a lot more fields to add, but it does show the sort of thing that can be achieved fairly quickly. There is plenty of documentation on the MigLayout website and, of course, the relevant jar to download and it was easy to create the following form:

and all this needed was the following code
import net.miginfocom.swing.MigLayout
application(title:'p45pt3',
//size:[320,480],
pack:true,
//location:[50,50],
locationByPlatform:true,
) {
panel(border:emptyBorder(12),layout:new MigLayout("wrap 4","[100][200][100][200]","")){
label("name :",constraints:'right')
textField("enter name", constraints:'wrap, width 150:150:')
label("reference :",constraints:'right')
textField("employee reference")
label("NI number :",constraints:'right')
textField("nino")
label("date of birth :",constraints:'right')
textField("dd-mm-ccyy")
label("gender :",constraints:'right')
textField("m/f")
label("starting date :",constraints:'right')
textField("dd-mm-ccyy")
label("job title :",constraints:'right')
textField("?")
}
}
This is by no means complete, there are no binds, for example, but it shows the layout quite nicely. What we wanted was simply two columns of entry fields, so here’s how it gets there:
1. new MigLayout(“wrap 4″,”[100][200][100][200]” ,”")
there are three arguments: the first is for the layout, here “wrap 4″ means that it will wrap to the next line after four fields (label, textField, label, textField); the second is for column constraints, what “[100][200][100][200]” gives is four columns with those widths (default in pixels); the final argument defines the row constraints, which is null at the moment.
2. add the various labels and textFields, I’ve used mostly defaults except for the “right” on the labels to right-justify the label text, and on the “enter name” textField I’ve used “wrap” to end that row and “width…” to define the actual width of the box (otherwise they are given the size of the initial contents).
I’ll use this style for the full form, but adding a few extra constraints to improve the appearance.
And then tomorrow, I’ll get it actually working…