sick of listening


I like Swing, it is a powerful toolkit that you can use to quickly put together graphical Java applications. In later versions of Java (think 1.4 and 1.5) it is snappy, it can look like a native application and be made to feel like one, too. This is all good. Many people complain it is too complex, however. It is complex, I'll agree, but you get used to it after a while. I certainly have.

But for the life of me, I sometimes wonder what the people at Sun are thinking. It's bad enough having to create a new inner class every time you add a listener to a Swing widget. This is a whole different rant in itself, but basically if you want to know when a user has changed the value of a field (typed some text, clicked a checkbox, made a selection from a list, etc) then you need to attach a listener to the widget. Need 20 widgets? That 's potentially 20 new classes, one listener for each. This kills your classloader performance for large applications.

But why must a different listener interface be used for every damm widget? I just created an application that used a JFormattedTextField, a JSpinner and a JComboBox and needed a PropertyChangeListener, a ChangeListener and a ActionListener (of all things!) to listen to all three widgets. If I had used a plain JTextField, I would have to use a DocumentListener instead. Arrrrg! One is a subclass of the other! I know JavaBean are back in fashion, so can we all just use PropertyChangeListeners? Pretty please?

Cleaning stuff like this up is one of the reasons I'd really like to see Sun make a real Java 2.0 (as opposed to a fake marketing Java 2 release). They could delete all the depreciated packages, classes, methods and fields. They could step back and fix the mirad of inconsistences, like this listener mess, that plauge the API. They could make it usable and learnable again. But this old news. Now that 1.5 is being called "Java 5", I don't see that happening. Ever.

Posted Thursday, October 28, 2004 at 21:40.


TrackBack URL for this post:


Add a Comment



Preview your comment before submitting.