What are the main things that an experienced Java SWT programmer should be aware of when moving to Swing?
What are the major differences which may be encountered? Any major differences in application design? Threading models? The way you go about constructing GUIs? An开发者_如何学JAVAy features of SWT which aren't available in Swing?
Few findings from my experience between Swing and SWT
- Rendering of Swing is a bit slower (my experience) and use much more memory
- Native look is possible just partially (depends on selected look'n'feel)
- Most of Swing components somehow implements MVC pattern (so you don't have to make your own data binding)
- It's possible to subclass components and it is used when you have to change behaviour of some component (so it's used often)
- Swing sends program generated events (I hate this behavior ;] )
- In Swing you don't have to call (a)syncExec() method (you don't have to care from which thread you are updating your GUI so much as in SWT, but be sure to read Swing threading policy (end of page) and Concurrency in Swing)
- Swing is really garrulous (compared to SWT)
- No more dispose() methods ;]
- Swing have standard layout manager in containers (see BorderLayout) and have different layout managers in basis (use MigLayout, it's for Swing and SWT as well and have no competitor)
- You don't have to know your parent on component instance creation, but you'll have to you .add(Component c) method on parent (container)
- Swing is not platform dependent (no more multi-builds for each platform and x32/x64)
- Swing have its own bugs (as other technologies, it's inevitable)
精彩评论