Tuesday, April 29, 2008

Using MiG Layout For Better Swing Development

I have forgotten a few libraries in my Better Swing Development article, and notably MiGLayout.

GridBagLayout is too verbose, and still feels too clumsy. This is why a while back I wrote a small tool to help visualize various GridBagLayouts for people who are not used to it. But it would have been much simpler to use a better layout instead.

MiGLayout is good, I managed to have good results without almost any practices on not so simple layouts. It also makes the code more concise.

Related to my previous post about SwiXml, and as SwiXml does not yet support MiGLayout, I was thinking how easy it would be to achieve something relatively similar. With proper code conventions it is quite easy to describe the GUI outside a Java file, for example, for an easy start in a Beanshell file.

The beanshell file would contain components construction, and MiGLayout of them afterwards, that's it. All listeners and component behaviours would be kept in java classes. With this kind of code split. The beanshell file is then extremely simple, as simple as the SwiXml.

MiGLayout also has plenty of extra functionalities like "hidemode 1" that can help automatically redoing the layout if a component becomes visible/invisible.

Using MiG Layout For Better Swing Development

I have forgotten a few libraries in my Better Swing Development article, and notably MiGLayout.

GridBagLayout is too verbose, and still feels too clumsy. This is why a while back I wrote a small tool to help visualize various GridBagLayouts for people who are not used to it. But it would have been much simpler to use a better layout instead.

MiGLayout is good, I managed to have good results without almost any practices on not so simple layouts. It also makes the code more concise.

Related to my previous post about SwiXml, and as SwiXml does not yet support MiGLayout, I was thinking how easy it would be to achieve something relatively similar. With proper code conventions it is quite easy to describe the GUI outside a Java file, for example, for an easy start in a Beanshell file.

The beanshell file would contain components construction, and MiGLayout of them afterwards, that's it. All listeners and component behaviours would be kept in java classes. With this kind of code split. The beanshell file is then extremely simple, as simple as the SwiXml.

MiGLayout also has plenty of extra functionalities like "hidemode 1" that can help automatically redoing the layout if a component becomes visible/invisible.

Friday, April 25, 2008

_the_ Google 1998 paper

I have just read "the anatomy of a search engine" from S. Brin and L. Page. For those who don't know, it is _the_ Google paper. I have read other google labs papers in the past. What I like in this one is that you can follow how they came into having the Google ideas, how they assembled their ideas.

I should have read that a long time ago.

_the_ Google 1998 paper

I have just read "the anatomy of a search engine" from S. Brin and L. Page. For those who don't know, it is _the_ Google paper. I have read other google labs papers in the past. What I like in this one is that you can follow how they came into having the Google ideas, how they assembled their ideas.

I should have read that a long time ago.

Fedora 9 Already Stable


I "upgraded" my home computer to Fedora 9. "upgraded" because I reinstalled the OS instead of using the upgrade procedure. I have had so many issues with "partial" upgrades in the past (with any distro).

Although it is the preview/RC1 version, Fedora 9 is already as stable as a release IMHO. No issues so far, it feels more polished than Fedora 8. OpenJDK 1.6 is there. Firefox 3 is there. Not a single problem with kernel 2.6.25 (while I had plenty with the 2.6.24 ones).

Even Linus's wife uses it!

Fedora 9 Already Stable


I "upgraded" my home computer to Fedora 9. "upgraded" because I reinstalled the OS instead of using the upgrade procedure. I have had so many issues with "partial" upgrades in the past (with any distro).

Although it is the preview/RC1 version, Fedora 9 is already as stable as a release IMHO. No issues so far, it feels more polished than Fedora 8. OpenJDK 1.6 is there. Firefox 3 is there. Not a single problem with kernel 2.6.25 (while I had plenty with the 2.6.24 ones).

Even Linus's wife uses it!

Thursday, April 24, 2008

SwiXml Review

Externalizing the screen layout is a natural step for many applications. It can be because a customer might want a slightly different presentation, or just for the sake of clearly separating layout code, or for using a kind of screen generator. Back in 2003, I wrote a small utility to help with GridBagLayout, nothing fantastic, but there was the feature of saving a generated layout in XML (or Beanshell) and using it in an application.

SwiXml saves a bit more than a layout as it instantiates the components as well, allowing to represent a hierarchy of components in XML. But it does not more than that. The "no generation" approach is interesting, I bet the author thinks the XML should be kept concise enough to be used easily without using a kind of generator. the XML is almost a mirror of Java code, but fortunately makes layouts more compact and easier to read. I tried version 1.51, and while it is quite well done, its documentation is a bit lacking and to me an important functionality is missing:

There is no "component" tag by default. One needs to explicitely name the class of component we want to add. I think there could be a component tag that instantiate an 0 parameter constructor by default, using reflection for example. The class of component to instantiate would be found through the field name.

Fortunately SwiXml is quite well done and this is not that big of an issue since you can just interpret new tags with 1 line of code:
engine.getTaglib().registerTag("datecombobox", DateComboBox.class);

for a Jide DateComboBox.

I said documentation was lacking, because in my first non Hello World trial, I wanted to use the standard constant names for GridBagConstraints (RELATIVE,REMAINDER, FIRST_LINE, LAST_LINE, ...). Putting <gridbagconstraint anchor="FIRST_LINE">did not work. By reading the code, I found out you could achieve it but you have to do <gridbagconstraint anchor="GridBagConstraint.FIRST_LINE">.

In the end SwiXml left me with a good impression. It is non intrusive, and handle well enough what it is done for. One major drawback, you can only use either BorderLayout or GridBagLayout or FormLayout (from JGoodies).

SwiXml Review

Externalizing the screen layout is a natural step for many applications. It can be because a customer might want a slightly different presentation, or just for the sake of clearly separating layout code, or for using a kind of screen generator. Back in 2003, I wrote a small utility to help with GridBagLayout, nothing fantastic, but there was the feature of saving a generated layout in XML (or Beanshell) and using it in an application.

SwiXml saves a bit more than a layout as it instantiates the components as well, allowing to represent a hierarchy of components in XML. But it does not more than that. The "no generation" approach is interesting, I bet the author thinks the XML should be kept concise enough to be used easily without using a kind of generator. the XML is almost a mirror of Java code, but fortunately makes layouts more compact and easier to read. I tried version 1.51, and while it is quite well done, its documentation is a bit lacking and to me an important functionality is missing:

There is no "component" tag by default. One needs to explicitely name the class of component we want to add. I think there could be a component tag that instantiate an 0 parameter constructor by default, using reflection for example. The class of component to instantiate would be found through the field name.

Fortunately SwiXml is quite well done and this is not that big of an issue since you can just interpret new tags with 1 line of code:
engine.getTaglib().registerTag("datecombobox", DateComboBox.class);

for a Jide DateComboBox.

I said documentation was lacking, because in my first non Hello World trial, I wanted to use the standard constant names for GridBagConstraints (RELATIVE,REMAINDER, FIRST_LINE, LAST_LINE, ...). Putting <gridbagconstraint anchor="FIRST_LINE">did not work. By reading the code, I found out you could achieve it but you have to do <gridbagconstraint anchor="GridBagConstraint.FIRST_LINE">.

In the end SwiXml left me with a good impression. It is non intrusive, and handle well enough what it is done for. One major drawback, you can only use either BorderLayout or GridBagLayout or FormLayout (from JGoodies).

Thursday, April 17, 2008

Better Java Swing Development

It has been a while since I have looked at the different options for building GUIs in Java. I like the approach taken by Eclipse, they provide not only GUI components, but a complete GUI application framework. Several years ago, I have stolen ideas from it (how they manage plugins) and applied it for Swing applications. This worked out quite well. The Netbeans platform now offers a more interesting alternative if you have to do Swing. The major drawback when compared to Eclipse, is that since the beginning Eclipse was all about making a platform, while Netbeans copied that idea only relatively recently and is less active about making it so. IBM uses Eclipse foundations for many of their products successfully.

Unfortunately on many projects, a Swing application is already there and all you have to do is add more screens, more forms. What I am trying to see here, is what could help Swing development is those cases.

JGoodies


JGoodies is old now, but can be quite useful in creating nice looking forms quickly. It is basically all around a layout better tailored to forms that the can do everything GridBagLayout.
It can help but it does not make a significant difference vs good practices with the GridBagLayout.

Jide Software


Jidesoft provides much more than JGoodies, but is not free (except the Jide Common Layer). I have used it in the past and found their API quite clean and easy to use. They offer more elaborated Swing components that should be part of the JDK. They started to go to the platform area only recently with their Jide Desktop Application Framework, which is not free either. I am not sure I would base an application around an unfree framework.

SwiXAT


It is a recent BSD licensed project based on top of Swix. It is basically MVC for Swix, with command binding in XML. I need to look more into it, it seems to provide an "application framework" as well where you have to launch your app through a SwixAt class (which IMHO sucks). I hope it is not a requirement and that only parts of it can be used and integrated into an existing application. I will hopefully have time to try it more concretely and will blog about it. In any cases it looks interesting.

SwiXml

An Apache licensed project, it seems like a decently used way of laying out swing components in XML, inspired by XUL. It might just be enough. Or is it just too similar to  Java code translated to XML? I need to investigate this more.

JavaFX

JavaFX is probably the serious alternative to SwiXml. I like the idea of a better grammar to lay out and assemble components instead of using XML. Unfortunately it seems a bit invasive to start using for a part only of an application

I took a quick look at Swing Application Framework (JDNC2 redone once again). While it has interesting use of annotations, it seems very far from what Eclipse offers. And I don't feel like it will improve working with Swing a lot. I think except JavaFx, Sun seriously fucked around during many years with Swing. IBM has been much more focused and effective.



Better Java Swing Development

It has been a while since I have looked at the different options for building GUIs in Java. I like the approach taken by Eclipse, they provide not only GUI components, but a complete GUI application framework. Several years ago, I have stolen ideas from it (how they manage plugins) and applied it for Swing applications. This worked out quite well. The Netbeans platform now offers a more interesting alternative if you have to do Swing. The major drawback when compared to Eclipse, is that since the beginning Eclipse was all about making a platform, while Netbeans copied that idea only relatively recently and is less active about making it so. IBM uses Eclipse foundations for many of their products successfully.

Unfortunately on many projects, a Swing application is already there and all you have to do is add more screens, more forms. What I am trying to see here, is what could help Swing development is those cases.

JGoodies


JGoodies is old now, but can be quite useful in creating nice looking forms quickly. It is basically all around a layout better tailored to forms that the can do everything GridBagLayout.
It can help but it does not make a significant difference vs good practices with the GridBagLayout.

Jide Software


Jidesoft provides much more than JGoodies, but is not free (except the Jide Common Layer). I have used it in the past and found their API quite clean and easy to use. They offer more elaborated Swing components that should be part of the JDK. They started to go to the platform area only recently with their Jide Desktop Application Framework, which is not free either. I am not sure I would base an application around an unfree framework.

SwiXAT


It is a recent BSD licensed project based on top of Swix. It is basically MVC for Swix, with command binding in XML. I need to look more into it, it seems to provide an "application framework" as well where you have to launch your app through a SwixAt class (which IMHO sucks). I hope it is not a requirement and that only parts of it can be used and integrated into an existing application. I will hopefully have time to try it more concretely and will blog about it. In any cases it looks interesting.

SwiXml

An Apache licensed project, it seems like a decently used way of laying out swing components in XML, inspired by XUL. It might just be enough. Or is it just too similar to  Java code translated to XML? I need to investigate this more.

JavaFX

JavaFX is probably the serious alternative to SwiXml. I like the idea of a better grammar to lay out and assemble components instead of using XML. Unfortunately it seems a bit invasive to start using for a part only of an application

I took a quick look at Swing Application Framework (JDNC2 redone once again). While it has interesting use of annotations, it seems very far from what Eclipse offers. And I don't feel like it will improve working with Swing a lot. I think except JavaFx, Sun seriously fucked around during many years with Swing. IBM has been much more focused and effective.