tags:

views:

1085

answers:

8

After spending a lot of time and code on programming in Swing, I thought this can't be state-of-the-art Java GUI building. After not finding a user-friendly visual gui bilder for eclipse I stumbled upon declarative GUI building with XML UI toolkits... and I thought: This must be it! I think it's the right way to go, easy and also close to web-programming.

But after looking around in the web and on SO, I got the impression that it is not very common! Although there are many implementations and APIs, it seems like most of them are kind of dead and had no updates in the last 5 years..

So I wonder: Is my feeling right, that XML is not very widespread for java GUIs? And if so - what are the reasons? Maybe it couldn't become accepted or it has some major drawbacks or people are doing everything in the web instead with fatclients or there are better alternatives, maybe javafx?

I just need to know if it is worth spending time in that area or better look for alternate ways. As I dont read developer magazines I just don't know what the trends in gui building are and which technologies are believed to have a future. But I can't imagine that people still spend so much time on writing nasty swing (or swt) apps.

+2  A: 

Sun's answer to that seems to be JavaFX.

It has a declarative language for specifying the GUI and there will be builder apps as well.

Thilo
JavaFX is a bog standard imperative language, not actually a declarative language. What it does have is syntactical support for setting a load of properties at initialisation time (plus binds).
Tom Hawtin - tackline
I just took a deeper look into JavaFX and it gives a good impression. basic controls are implemented with much lesser code. bindings are convenient and together with css-styling and charts and the coming authoring tools its something I will definitly spend more time on!
räph
A: 

The answer is surely not going to be XML. What problem are you trying to solve? You want to have reusable building blocks, and a compact way of describing them. I don't see XML helping you there.

[edit] Creating a java code equivalent of XUL would be an immense improvement on XUL. XML makes it really, really hard to do good separation of concerns and once and only once. It is however perfect for the mongolian horde approach. You need a layer on top of swing, it only provides the building blocks.

Stephan Eggermont
it's just that i think swing coding is nasty.i like the structured, hierarchical design of xml documents and the clear separation of functionality, structure and design. personally i think it's better to read. and judging from what i saw about xul, it needed much less code than swing.
räph
A: 

I'd second Thilos suggestion with javaFX. Additionally the trend is pointing to webapps, so I think that in the long run javaFX and web based UIs will catch up to swing+swt GUIs.

Patrick Cornelissen
+1  A: 

Five to ten years ago XML was very popular. Although fine to provide some kind of standardisation for transferring data between heterogeneous systems, it's not suitable for programming. It always starts with the easy stuff, and lets declare everything. But any real system requires code. XML then falls down. There is also the problem that XML is a bad syntax for humans, and even languages like Java are easier to read.

On the other hand, there is clearly a need for the rails of GUIs. Naked Objects is the closest reasonable attempt I have seen.

Tom Hawtin - tackline
You should learn more about XUL. It's never used alone, obviously; it's scripted with JavaScript (or, in the case of Miro, Python). Try it. It's really awesome.
niXar
+2  A: 

There is some prototype work going on for e4 (Eclipse 4), which would allow building a GUI by editing an Ecore model and customizing it via CSS.
See this blog post for some details and instructions to try it out yourself.

Zsolt Török
+1  A: 

I came to the same conclusions as you about the declarative frameworks out there. It is not worth learning a new GUI syntax unless it's widely supported. XUL as an interface language is widespread, but there is no java rendering framework for it. I'd say HTML+CSS+Javascript and a Servlet container is the best Java platform for GUIs today, but sadly I haven't found a platform independent way to display web pages like a desktop application.

A: 

I do all my swing stuff by hand and none of my application is nasty. If you do not know how to create usable and good looking UI there is no technology to help you.

Rastislav Komara
cool it! maybe I didn't express myself very well. my apps aren't nasty at all (they are the most beautiful...) but the process of building a complex gui with swing is clearly nasty, at least for me :)
räph
+2  A: 

There new fresh and interesting approach - it uses YAML. Check it out at code.google.com/p/javabuilders/

eugener