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.
Part 3 of ?: Swing Application Best Practices
The Application and Where to Start
If you haven't seen Part 1 and Part 2 of this series I invite you to read those. I'm really excited about the amount of response I have received on these posts and I really think something good can come out of this. The only problem thus far is I have received an email from 1 person wanting to join the project. I can't do this alone and I can't do it with 2 people. For this to work I really need more participation on the actual project so if you would like to help in any way please send me a gmail address to gdboling AT you know the rest.
We should start talking about what kind of application we can build that will provide a good foundation for everything we want to try and accomplish. Here are a few points to think about as we try and come up with ideas:
- It has to be simple yet interesting
- It needs to support multiple forms
- It should try and use as many components as makes sense. It doesn't need to a be SwingSet demo but at the same time, if a concept can't cary over to multiple components we need to provide good examples.
- It doesn't have to be RIA. I believe the things we are trying show and learn can apply to any type of Swing application. There are just some things that RIA's require that aren't what we care about right now and I don't want to get hung up on something.
- Persistence shouldn't matter. We should begin by mocking it if we need to in order to keep things simple. If later we want to supply different persistence layers then fine. But that is not our goal.
So let's hear some wonderful ideas. After I get a few I'll chime in with the ones I have in mind.