<< Part 3 of ?: Swing Application Best Practices | Home | Java6 Drag and Drop JTree to JList >>

This Is What Ticks Me Off With Sun and Swing

So I have been spending most of my evening trying to get drag and drop from a JTree to a JList to work with Java6's alleged "simpler D&D support". Simple is relative. I need to actually transfer the user object from the DefaultMutableTreeNode for my application to really work correctly so that meant providing my own TransferHandler and Transferable implementations.

Well, I sort of got it working but wanted to spruce it up with a nice icon when the node is being dragged. Looking at the API (and in my case the source code) I found a method:

public Icon getVisualRepresentation(Transferable transferable)

that I can simply override and provide my icon. So I did this but no icon was showing up. Debugging I then found this method was never even called. Google time!! Found this:

http://bugs.sun.com/view_bug.do?bug_id=4816922

Reported in 2003. Still not fixed. Ok, so drag and drop works. But it looks like garbage and I had a hard enough time getting this to work as is. I personally don't feel like I should have to go and override all the drag source and drag target nonsense just for something like this. Absolutely rediculous that Sun can't (won't) fix something like this. I'm curious if this works in JavaFX only to the extent of if it does, why can't they backport it into Swing?

So freaking ticked off right now because even though this is a trivial issue that doesn't stop my app from working Swing is full of these kinds of bugs that have been sitting for years.



Re: This Is What Ticks Me Off With Sun and Swing

I've been programming GUIs in Java for about 8 years now and I'm finally ready to give up on Swing altogether. Fortunately everyone wants "web 2.0" and "ajax" these days and no one is asking me to build desktop GUIs much anymore, so the transition should be an easy one. No more Swing for me, it's time to learn JSF, Ajax, Backbase, all that new stuff.

Re: This Is What Ticks Me Off With Sun and Swing

@Anonymous: honestly, although I admit Swing has its defaults, it's still one of the best GUI environment I've been working with since I started IT (~20y ago!) I wish you good luck with JSP, Ajax and so forth, you may miss Swing sooner than you expect;-)

Re: This Is What Ticks Me Off With Sun and Swing

Take a look on Wicket for web development and you'll be able to reuse much of your Swing know-how.

Re: This Is What Ticks Me Off With Sun and Swing

With so much Swing-style coding done, you really should give Google Web Toolkit a try. I bet you can transition from Swing to Ajax in no time.

Re: This Is What Ticks Me Off With Sun and Swing

Go for gwt. It's great. You can almost word-for-word rewrite swing applications.

Re: This Is What Ticks Me Off With Sun and Swing

Not that simple really. If you used any other fat client GUI library you would find all kinds of mess you dont want to deal with. I know Ive coded in them all. So override some stuff or hack up a solution yourself. Jumping to the web will introduce you to lots of stuff that doesnt work...AT ALL. I understand the emotion, but javascript and ajax isnt your golden brick road.

Re: This Is What Ticks Me Off With Sun and Swing

Google Web Toolkit :)

Re: This Is What Ticks Me Off With Sun and Swing

Seems like complaining about Sun/Swing/JavaFX has become popular.

Here's some recommended reading for people who wants to complain about Sun or Swing.

I am developing on web (JSF, PHP/Symfony, a little Wicket), and also a little Swing, so I feel qualified to comment on this issue.


Add a comment Send a TrackBack