Avoiding the GridBag ... reminds me of GridBagPanel

Scanning through JavaBlogs, I came across a blog entry from java.net entitled Avoiding the GridBag that talks about the packer project - a way to simplify the GridBag API. This reminded me of a cool little component that I created for a Swing project a few years ago.

If you've done any Swing programming, you'll know that building forms in Swing can be a tricky process, especially if you decide to use the infamous GridBag layout manager. To make this task easier, I created a GridBagPanel - essentially a Swing JPanel that has GridBag set as its layout manager. GridBagPanel provides a very simple API that can be used to build forms (like the one shown below) very easily.

A form created using GridBagPanel

The following code sample shows how simple it is to build a form like this.

	// create the components as usual
	JTextField toTextField = new JTextField();
	JTextField ccTextField = new JTextField();
	JTextField subjectTextField = new JTextField();
	JTextArea messageTextArea = new JTextArea(4, 32);

	// then build a GridBagPanel, 4 rows by 2 columns
	GridBagPanel p = new GridBagPanel(4, 2);

	// and finally add rows specifying the label and the component
	p.addRow("To", toTextField);
	p.addRow("CC", ccTextField);
	p.addRow("Subject", subjectTextField);
	p.addRow("Message", new JScrollPane(messageTextArea));

I had completely forgotten about that until the packer project came up, so perhaps I should dig out the source code and make it availble under an open source license. Anybody think there's a demand for this sort of stuff? I also have a whole framework for building standardised dialogs and panels that conform to the Java Look and Feel guidelines if I can find it! I have the slides from a BOF that I gave at JavaOne 2000 about this stuff and I'm sure I have the code somewhere.

Tags :

London Java Meetup last night

I went to the Java Meetup last night at SOS in London and again it was another good evening, even though there were only five of us. So, who came along? Well, Ken and Don were there again and we got to meet Stefan and Jeremy who has a blog at javanicus.com. Incidently, I found out that this is pronounced jar-vanicus rather than java-knickers. ;-)

We talked about many things, mostly technology related, including open source, AOP, experiences with green-screens and mainframes (this is becoming a recurring theme!) and Java. Check out Jez's blog entry for a much better account! However, I do have a photo that Ken took.

Java Meetup @ SOS, 21st July 2003

From left to right, we are Don, myself, Stefan and Jez. Notice that I even printed signs so that newcomers could find us! Oh well, a good night. Until next time...