As the author of CookSwing, a tool that does what you need, I've given this subject a long hard look before doing the actual implementation. I made a living writing Java Swing GUI applications.
IMO, if you are going to use any kind of imperative programming languages to describe Java Swing component, you might as well just use Java. Groovy etc only adds complications without much simplification.
Declarative languages are much better, because even non-programmers can make sense out of it, especially when you need to delegate the task of fine tuning of specific layouts to artists. XML is perfect for declarative languages (over other choices) because of simplicity, readability, and plenty of editors/transformation tools etc available.
Here are the problems faced in declarative GUI programming, not in any particular order. These issues have been addressed in CookSwing.
- Readability and simplicity. (JavaFX is not any simpler than XML. Closing tags of XML helps reading quite a bit, and doesn't add extra typing much since XML editors usually do it for you)
- Extensibility. Very important, because custom Swing components will come up for any non-trivial projects.
- GUI layouts. Also very important. Being able to handle BorderLayout, GridBagLayout, JGoodies FormsLayout, etc are practically a must.
- Simplicity of copy/paste. In the course of the designing the layout, it is necessary to try out different ones. So one need to be able to copy / paste and moving things around. XML is better because the hierarchy of components and layouts are easy to see. JavaFX is somewhat problematic due to multi-line attributes and indentation issues. Having a good editor is a must, and there are plenty of good XML editors.
- Templates (i.e. being able to include another layout file) is very useful for consistent look. For example, one might want to have a consistent look of dialogs, button panels, etc.
- Interactions with Java code. This is crucial. Some GUI components can only be created with Java code (for whatever the reason). It is thus necessary to be able load these objects. It is also necessarily being able to directly hook up listeners and other Java objects/components within the XML code. Using ids to hook them up later WILL not work well, as it is very tedious.
- Internationalization (i18n). Being able to load text / string from a resource bundle rather than hard coded text. This feature can be crucial for some applications.
- Localization (l10n). The advantage of declarative programming (particularly with XML) is that you can just switch to a different GUI form for a specific locale and that's it. If you code with Java or any other imperative languages, it is not so easy.
- Error check / tolerance. Initial designs often will contain errors here and there. Sometimes the error might be because the corresponding Java code hasn't been designed yet. Or an icon resource is missing. Dealing with errors with imperative coding is extremely tedious. Thus it is desirable to be able to locate the errors, yet at the same time being error tolerant, so the preview of the GUI layout can be made as early as possible.
- GUI component replacement. That is, replace textfield which used to have JTextField with some fancier version of components. Replace the meaning of dialog with some fancy UI dialogs (such as JIDE's) instead of JDialog. This feature can save significant amount of efforts. XML itself is also useful due to XSLT and other transformation tools.
- Beyond Swing. Because sooner or later you will find many component configurations use object types such as arrays, icons, images, vectors, etc.