Arrrrrgh, Swing!

That’s not documentation. It’s a marketing document to prepare interested parties before the product is ready.

It’s ridiculous to offer it as LaF docs, since it has only ONE PARAGRAPH and a 3-way circular link in the glossary. It also has a very short appendix explaining how to switch the current LaF. Wow!

To recap: 0.000 documentation covering Swing LaFs. Except how to select one at runtime (and even that is incomplete!)

I recently bought a book to help me with my Swing woes, “Swing 2nd Edition”. It’s good and bad…there are a number of typos, unfortunately, and the index is total crap - but even with these things it explains so much better the fundamental concepts of Swing. I’ve been through the Java Tutorial on Swing, I own the “Core Java Volume 2: Advanced Features” for 1.2, 1.3, and 1.4 - none of which were particularly helpful when developing a Swing app that wasn’t directly copied from the book.

I highly recommend this book, but if I were you guys I might wait and hope for “Swing 3rd Edition” - but honestly, it’s cleared up so many little misunderstandings that I had about Swing from all the other so-called documentation - it was the light at the end of a 4 year tunnel, I tell you.

Some more resources for anyone still reading this thread, these presentations are great.

For people who think Swing is slow:
Professional Swing: Threading

For people with other Swing gripes (L&F, ease-of-use):
Professional Swing: Creating Polished Applications

the above should be on the very first page in the Swing tutorials. would save everyone lots of trouble. thanks for this!

ad Swing in general:

  • The biggest problem i have with Swing is that all the defaults are wrong, for example in GridBagLayout. what you want most is not the default. I resorted to writing my own util classes to help with getting GBL to work nicely. nevertheless, it’s a PITA. (ad: first poster, what you want to do in GBL works, you just need to know how)
  • Another issue is that there isn’t just one way to do something. Usually, you can achieve the same result in a zillion different ways. Many of which are subtly wrong. That means only one thing: Badly designed framework.
  • There are no guidelines on how to do things. Sun doesn’t tell you, for example, how to use ActionListeners. Do whatever you want.
  • The above holds true for Swing itself too. If you look at the source code, it’s a huge mess, where everybody does whatever they think they want to do. No conventions, messy code, outright stupid mistakes, lots of static state-keeping fields… There were no coding guidelines or if there were, they were not enforced…
  • No native L&F. How hard would it be for Sun to just use the Windows L&F that is installed on the system? Then Java apps would just look like any other app, even after installing SP-whatever. Emulating this with their own bitmaps is just silly. Take SWT as an example in this regard. The app looks just way more professional.

[/rant]

I know about threading and these things (and Foxtrot! Yey!) so speed isn’t an issue. In fact, Swing is damn fast. I am timing my app and creating even very complex layouts with images and stuff takes usually in the range of 30ms. That’s FPS-ready response time. Swing is a lot of things, but it is not slow.

[quote]The most recent class I’ve added to my project is a layout manager that only handles two objects: it gives 25% of the space to one, and 75% to the other. It’s bloody simple, and has solved all my layout problems. I’m absolutely amazed that I couldn’t shoehorn any of the current layout managers into performing this trivial task. Ho-hum.
[/quote]
In 1.5 (5.0) you can do that with SpringLayout. Previously SpringLayout was rather incomplete. However SpringLayout is intended to be used by gui builders and not directly via hand coding.

I did something similar, but with more options and a sprinkling of cleverness. I have been threatening to tidy it up, document it, and put it online for free for…oh, about 8 months now. Whoops.

Hopefully I’ll get around to it once JGFv3 is live. That thing is now a great big monster clinging to my back, weighing me down :(.