Monday, December 21, 2009

SWT instead of AWT packages

Today I got annoyed using eclipse code completion to add a KeyAdapter on a SWT component. Instead of adding the SWT KeyAdapter (since it's a SWT widget), eclipse suggests the AWT KeyAdapter before the SWT KeyAdapter. The result of this is that I often choose the wrong one.
Same thing with other classes like KeyListener, MouseListener...

So I was looking for a solution, eclipse should ignore the java.awt package.
I have not found a way to handle this for the whole workspace using preferences.
I now exclude the java.awt package in all my UI bundles from their Java Build Path.

Maybe you have had the same "trouble" and never thought about getting rid of it :-)


Boris Bokowski said...

Does Preferences > Java > Appearance > Type Filters not work for you?

Stampie said...

The type filters mentioned by Boris are exactly for this reason. I use it right now for this reason.

Flavio Donzé said...

That's exactly what I was looking for. Thanks Boris!
Way better solution.

Application Development said...


Thanks for sharing. I like these types of topic and wants to read more post on this topic.

Application Development Company India