3 ms·
I haven't touched Java UIs since university - back then we were taught about AWT and Swing. I remember being unhappy with AWT because it never worked right and
by DaiPlusPlus 9y ago
I haven't touched Java UIs since university - back then we were taught about AWT and Swing. I remember being unhappy with AWT because it never worked right and was inflexible - and I was equally unhappy with Swing because it never looked or felt native - and for some reason window resize redrawing was done slowly. I first heard about SWT more recently and it brought back my faith in the native desktop, but I've never used it.
In your experience, how well does SWT handle the differences between platforms (fundamental things like macOS vs Windows' menu-bars, to smaller things such as the arrangement of buttons in a dialog)?
What is the graphics performance like too?
- MarkMc 9y agoYes AWT/Swing was bloated, buggy and slow - Sun's poor UI implementation really doomed Java on the desktop. But then IBM came along and did it right: SWT is super fast and lightweight because it simply calls underlying native API like Cocoa or Win32. It's always been super fast even when I started 10 years ago. Layout of components on screen is straightforward and much easier than Swing. (Just use GridLayout 90% of the time). I have to specify different margins and fonts for Mac and Windows and you will need to change the order of the OK/Save and Cancel buttons, but that's not a big problem. (In fact there is a library called JFace which can do alot of this stuff for you, but it comes with a lot of baggage so you may just be better off with pure SWT). The difference in menu bars is perfectly handled by SWT, and it includes Mac-specific menu options like having the Preferences and Quit menu item in the application menu. You may notice a loss of fidelity here and there - for example, on Mac my error messages don't look exactly like a standard Mac error dialog: http://imgur.com/a/znehj http://imgur.com/a/znehj I'm sure I could fix this with 'if(mac)' and breaking out to the native OS, but in 10 years it's never been a high priority for me. -------------------------- By the way, here's a juicy story about why IBM developed SWT: http://www.mail-archive.com/jug-discussion@tucson-jug.org/msg00355.html http://www.mail-archive.com/jug-discussion@tucson-jug.org/ms... A few choice quotes: "At IBM we hated Swing from day one. Big, buggy, and looks crap" "All of the IBM developers are the same crowd who used to work with Smalltalk, and we reluctantly under management orders built our WebSphere Studio tools using Swing. It was a terrible, buggy, monster. In our initial previews when it was demo'd against Microsoft Visual Studio products all our users hated it just because of how it looked, never mind what it let you do" "Swing was so badly broken deep down in the way it reads windows events...they read their event queue in a way that can leave memory holes so we had to have our own loop polling the windows event queue to do this correctly.....We tried over and over to get Sun to fix this but Amy just didn't understand this" "Swing is like Java deciding not to do native IO using the operating system, but instead to use the disk motor arm API and read and write the disk data segments themselves."