I wonder if there are any suggestions for declarative GUI programming in Java. (I abhor visual-based GUI creator/editor software, but am getting a little tired of manually i
WindowBuilder, it a very nice plugin, which included GWT,XWT,SWT,Swing etc
If conciseness is important you might want to consider the double brace idiom:
new JFrame("My Frame") {{
setName("myFrame");
add(new JLabel("My First Label") {{
setName("myLabel2");
}};
add(new JLabel("My Second Label") {{
setName("myLabel2");
}};
}}
You then don't lose any of the power of a well known general purpose programming language (you know you are going to need it, and JellyTags suck). All you need is the one little extra idiom.
It's not used very much, because actually people pissing around with XML weren't solving real pain points.
In general you can use builder layers to abstract repeated code. GUI code doesn't have to be badly written, it's just that almost all of it is (including in text books).
You might have a look at javabuilders; it uses YAML to build Swing UIs.
A simple example from the manual [PDF]:
JFrame:
name: myFrame
title: My Frame
content:
- JLabel:
name: myLabel2
text: My First Label
- JLabel:
name: myLabel2
text: My Second Label
Alternatively:
JFrame:
name: myFrame
title: My Frame
content:
- JLabel: {name: myLabel2, text: My First Label}
- JLabel: {name: myLabel2, text: My Second Label}
Or even:
JFrame(name=myFrame,title=My Frame):
- JLabel(name=myLabel2, text=My First Label)
- JLabel(name=myLabel2, text=My Second Label)
give Swiby a try: http://swiby.codehaus.org/
"Swiby is a blend of Swing and Ruby for truly rich distributed applications." In other words Swiby is a domain specific language mixing swing and ruby.
I can find the following examples of what you're asking for:
something new...XWT, will be included in eclipse e4