replace qualified name with auto add import

With Eclipse 3M7 (and lesser editions), if I were to code something like javax.swing.JFrame in the middle of a code block, and then press the space bar, this code is automatically shortened to JFrame and an import statement is added, if it didn't already exist and if I've selected to "Automatically add import instead of qualified name".

Is there any way to get IntelliJ 4 to behave similarly?


Not IDEA itself, but there's an inspection in the InspectionGadgets plugin which will do just that. It's called "Unnecessary fully-qualified names" in the "Verbose or unnecessary constructs" section. Switch it on under "Settings/Errors" and you're good to go.

--Dave Griffith


Do you know that if you type just JFrame, then press Alt+Enter, IDEA will import javax.swing.JFrame?


Thank you for the plugin tip, Dave.

And thank you, Keith, for the very nice shortcut tip. I won't likely be missing that Eclipse feature anymore.

I suppose that Alt+Enter is the solution to many things with IDEA.


Please sign in to leave a comment.