I like Swing. I have been using it for quite some time now and I really don't have any problems with it. I am just asking this our of pure curiosity. What makes Swing Slow? Please don't turn this into a pro/anti Swing debate. I like Swing just fine. I just want to know if someone knows. Thanks.
hello Gregg, this is an interesting question. I think, the performance of Swing depends on many different little factors starting with the operating system and ending with threads. At the moment, I work on an interface that loads lots of database rows. First, the interface did wait for all the data from the database and then rendered it. As the data got more and more, the interface "slowed down" of course, as it took longer to get the data and render it. Now, I changed the behaviour to display the data as soon as it comes out of the backend. The search takes as long as before (maybe even longer, as the view has to be updated all the time), but the user does have the impression that it is very quick. In fact, if the gui provides a good and steady feedback it seems to be faster than a gui that has really the same performance but does not provide a steady feedback. (The BeOS gives a very fast graphical feedback to the user, so it seems (and is) lots of times faster than other operating systems.) Another important point is that the gui does not freeze on backend actions. Multi threading is a fine solution. ok, this is not really the answer to your question, but it is something I experience all the time: There are many little things that improve the usability and they often seem to accelerate the performance at the same time. In the time of big CPUs and RAMs and the Hotspot and other neat compilers I think swing is fast enough. But at the same time, the API provides lots of ways for the ignoring programmer (and I certainly am one of those) to slow down a program. I don't mean that the API is bad but that it provides lots of solutions for one problem and not all of those are good. The net if full of little tips and tricks how to program swing but only part of them are up to date and improve performance. The source code of the jdk does not really help in many cases. For example: Swing classes still use Vector internally. Vector inherits Collection but they never bothered to add constructors that take a Collection as argument. On the other hand, I found an article (I think even by some Sun people) that recommends to use a HashMap as backing store of a TableModel (and not a Vector as the DefaultTableModel does). and so on... cheers Chantal
Thanks! That was actually quite informative. I would like to know more details about the last part of your post where you talked about Swing classes still using Vector internally and other related information. For example, I have read that an ArrayList is faster than a Vector, so why doesn't Sun change the underlying API to use an ArrayList instead? Articles or links about that kind of information is what I am looking for. Also, Is there something what handles the painting of the Components that make slower? Seems like I heard something about this a while back and can't remember where. Thanks [ September 20, 2002: Message edited by: Gregg Bolinger ]