Eclipse doesn't find javax.swing
There must be an installed (and selected) JDK in Eclipse:
Window > Preferences > Java > Installed JREs
The project must be configured to use that JDK:
Project > Properties > Java Build Path > Libraries
there should be an entry like "JRE System Library [JDK7]" in the list. If not press:
Add Library... > JRE System Library
The project should have been created as a "Java Project":
Project > Properties > Builders
should include "Java Builder"
The accepted answer did not work for me.
This is how I solved it:
Right-Click on your project, select Properties
Go to Java Build Path
Click Libraries
, then Add Library ...
Select JRE System Library
Click on Execution environment
and select JavaSE-1.7
or JavaSE-1.8
Click Finish
, then Apply and Close
.