Monday, March 31, 2008

Seam / JBoss article by yours truly on devx.com

With all the excitement over Java Builders (well, at least I'm excited), I forgot to mention my new article on web development using Seam, RichFaces and JBoss Tools:

http://www.devx.com/Java/Article/37547

Hope it will be useful for those of you evaluating Seam...

JavaBuilders.org - now live! The power of Groovy builders coming to Java...

Well, my initial experiments with MigLayout over the weekend have proven VERY productive.

Let's look at the GroupLayout example from the Swing tutorial:

The GroupLayout code required to accomplish this is Find.java

The equivalent Java Builder YAML file to accomplish this using MigLayout is a lot easier to understand and less verbose:
JFrame:
name: myFrame
title: Frame
content:
- JPanel:
name: groupLayoutPanel
content:
- JLabel: {name: label, text: "Find What:"}
- JTextField: {name: textField}
- JCheckBox: {name: caseCheckBox, text: Match Case}
- JCheckBox: {name: wholeCheckBox, text: Whole Words}
- JCheckBox: {name: wrapCheckBox, text: Wrap Around}
- JCheckBox: {name: searchBackwardsCheckBox, text: Search Backwards}
- JButton: {name: findButton, text: Find}
- JButton: {name: cancelButton, text: Cancel}
MigLayout:
constraints:
- label: cell 0 0
- textField: cell 1 0 4 1, grow
- caseCheckBox: cell 1 1
- wholeCheckBox: cell 2 1
- wrapCheckBox: cell 1 2
- searchBackwardsCheckBox: cell 2 2
- findButton: cell 5 0, grow
- cancelButton: cell 5 1, grow

With this, I have decided to take the project more seriously and create a proper URL for it.

From now on javabuilders.org will point to the standard Google Code site.

No code released publicly yet, but I hope to have a 0.1 release by end of this month.

P.S. I am still torn on the design of the layout manager...to keep the control constraints separate under the layout manager node, or allow entering them at the control level. Here's an alternate version of the layout above with the constraints embedded at the control level:

JFrame:
name: myFrame
title: Frame
content:
- JPanel:
name: groupLayoutPanel
content:
- JLabel: {name: label, text: "Find What:", constraint: cell 0 0}
- JTextField: {name: textField, constraint: "cell 1 0 4 1, grow"}
- JCheckBox: {name: caseCheckBox, text: Match Case, constraint: "cell 1 1"}
- JCheckBox: {name: wholeCheckBox, text: Whole Words, constraint: cell 2 1}
- JCheckBox: {name: wrapCheckBox, text: Wrap Around, constraint: cell 1 2}
- JCheckBox: {name: searchBackwardsCheckBox, text: Search Backwards, constraint: cell 2 2}
- JButton: {name: findButton, text: Find, constraint: "cell 5 0, grow"}
- JButton: {name: cancelButton, text: Cancel, constraint: "cell 5 1, grow"}
MigLayout


This is less verbose, but I find it is also less clear..and some different layout managers have more complex constraints than just pure text (e.g. GridBagLayout). Plus, in this case multiple MigLayout constraints that are comma-separated need to be escaped in quotes, since comma is a reserved character in YAML.

Any opinions on this?

Thursday, March 27, 2008

MigLayout - very interesting...

I've started looking at what is the best way to handle layouts in Java Builder UI files...just trying to wrap my head around the horrific code required by GroupLayoutManager forced me to do it.

Looking into MigLayout and liking it a lot...I think it's dynamic nature would fit into the dynamic paradigm of Java Builders very well:
http://www.miglayout.com/QuickStart.pdf

Thinking of making it the default layout manager in the project...

Tuesday, March 25, 2008

Java Builders...slowly coming alive

I recently started a new open-source project called Java Builders, inspired in equal parts by Groovy's builders (hence the name), Ruby on Rails and libGlade (for building GTK+ applications).

Please check out the code site:
http://code.google.com/p/javabuilders/

Much development to ensue throughout the coming months...the goal of this project is to obliterate any productivity differences between dynamic languages and Java by making building UIs in Java so simple and fast (regardless of whether it is Swing, SWT, Google Web Toolkit, etc) that nothing else can compare (even visual UI builders like Matisse).

Ambitious goal...payoff is potentially great...fortunately enough, if it fails no one will notice. :-)

The concept is simple:

a) define a UI (both controls and layout) in an external file (like Glade/libGlade in GTK+)
b) use YAML for the file format, instead of XML or JSON (like Ruby on Rails)
c) build the UI in a style similar to Groovy builders (but with the layout in the YAML file, not in code)

It's a Frankenstein creation, based on ideas pinched from other languages and applied to Java.

Stay tuned!