Aviv Cohn
Aviv Cohn

Reputation: 17173

Eclipse says I need to import a class, when I already imported it's whole package

In a class, I have this line:

import javax.swing.*;

However on the StyledDocument doc = new DefaultStyledDocument(); Eclipse gives me an error (red line under the text) and offers to import StyledDocument (javax.swing.text)

Weird. I imported the entire swing package, why do I also need to import the class specifically?

Upvotes: 0

Views: 411

Answers (1)

JB Nizet
JB Nizet

Reputation: 691635

Because the class is not in the javax.swing package, but in the javax.swing.text package. Imports are not recursive.

Upvotes: 5

Related Questions