Ok, so here is a good topic for conversation. I have a project that I am going to start working on in the very near future. This is a personal project of mine and a friends.
Part of the project requires an IDE of sorts for our toolset. I thought that writing my own from the ground up would be a good learning experience. I know I could use Eclipse and write a plugin or I could use JEdit or Netbeans foundation. But those aren't really options.
So now it comes down to which GUI library to use. I know Swing better than I know SWT. But with some of the things I need to do (syntax highlighting, etc) Swing can be a real pain. SWT has some nice classes for dealing with IDE features because the library was written to create an IDE. The problem with SWT is a) documentation, b) not knowing it as well as swing, and c) customizing and/or creating custom components is not as simple as it is with Swing.
So taking some of that into consideration, I would like to hear some arguments for and against both Swing and SWT. Which would you choose for a similar project and especially, why.
I'm now delivering the first alpha versions of an IDE based on Eclipse. My original prototype was a Swing-based implementation that used JEditorPane for an editor. I think I'm pretty well qualified to speak to this!
SWT, and especially JFace, are plenty powerful, but not many people appreciate all the capabilities of JEditorPane. Once you learn to implement your own EditorKit, you can make JEditorPane do some amazing stuff. The truth is, there's nothing you can do with one that you can't do with the other. The famous speed difference is just nonsense, and in fact, very big trees and tables actually perform better in Swing, due to the clever way Swing implements them. Anything you gain by using native painting is lost due to the overhead of calling native methods. So it's not about speed, not at all.
The main difference, as I see it, is this: say you want to implement what I call "parenthesis bouncing", that feature of an editor where typing a close paren or brace makes the cursor momentarily flash on the matching open paren or brace. If you're using JEditorPane, you know that you're going to have to implement it yourself. You use a JTimer and a KeyListener and you've got something working and tested in less an hour. But it doesn't look precisely like anybody else's parenthesis bouncing, and that bothers you a little. Still, it works, and you're ready to move on to the next feature.
In Eclipse/SWT/JFace, your first task is to figure out what they call parenthesis bouncing, so you can use their implementation. Depending on how similar your thought processes are to those of the Eclipse Foundation folks, this can take a long time. Eventually, you figure out you need to implement an ICharacterPairMatcher. That's easy enough to do, and in less time than it took to do the Swing version, you have something which works just like everything else on the Eclipse platform, and handles edge cases you might not even think of. But that lead time where you figure out what it's called is a killer.
So if you write using Swing, you'll write more code, but you'll know what you're doing. You'll probably be done faster, too. If you use JFace, you'll spend more time doing research and write fewer lines of code in the end. You'll also end up with something that has a more standardized look and feel, and you'll get some minor features "for free".
That was one of the longest non-answers I have ever read. Ok, not the longest. Kidding aside, thanks for the info. It did help. I of course am a Swing proponent so have been leaning that direction. But I don't ever want to count something out just because of my ignorance of it. I think that possibly, if this project were even less serious than what it is, I might consider it an opportunity to use SWT/JFace as a learning experience.
However, considering that I have a fairly high-level understanding of Swing it can still be a learning experience for me to do it using Swing. Speed has never even been an issue. I know exactly what you are talking about in that regard.
I actually did find a class in Swing that is used for the "parenthesis bouncing" in some apps. Basically it just highlights the pair when closing them. There is actually an Interface called Highlight in J2SE. I'm not sure what it's orginal purpose is/was, but I know it's used for that now.
Something that concerns me with both libraries is documentation. Swing has better docs than SWT/JFace (with the exception of the book I won a few weeks ago). The problem is, and has been talked about over and over, is the lack of definitive answers to questions. I can always find a "way" to do something. But no one seems to know if it is the preferred or correct way. It's always just "one way". It might make for a good weblog series though to discuss my trials and tribulations with this as it is being developed. I'll be sure and keep tabs and notes on problems I run into and solutions I might find. Maybe I can at least help someone else in the process.
I would still like to hear some other opinions on this. Thanks Ernest for the info. [ October 05, 2004: Message edited by: Gregg Bolinger ]
Originally posted by Gregg Bolinger: [QB] I actually did find a class in Swing that is used for the "parenthesis bouncing" in some apps. Basically it just highlights the pair when closing them. There is actually an Interface called Highlight in J2SE. I'm not sure what it's orginal purpose is/was, but I know it's used for that now. [QB]
Do you mean Highlighter ? Have you got any examples of how to implement the interface on a JTextComponent ?
I have yet to use SWT, but I must agree that the documentation for Swing is not the best. Still looking for that definitive book on the subject, I'm hoping that Zukowski's latest update due to be published later this year clears up some of the points, where in previous releases I became more confused than I was before reading his book. [ October 06, 2004: Message edited by: Nigel Browne ]