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

StackOverflow https://stackoverflow.com/questions/23523169

  •  17-07-2023
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top