0

So to import in eclipse you press ctrl shift O. One problem is that some classes cannot be identified such as java.awt.Color; However If I ctrl click a class java.awt.color is opened. so I have to manually scroll up to the package copy paste the package, import then the error is resolved. Is this an eclipse problem, Should I change the SDK?

It's shit I have to keep doing it.

msoper342
  • 5
  • 2

1 Answers1

1

You can start typing

import Color

and then hit Ctrl-Space for Content Assist, and choose Color - java.awt from the drop down.

Also works if you just start declaring a variable on any line where declarations are allowed

    Color

and hit Ctrl-Space, and when you choose Color - java.awt the import statement will be added automatically.

Ctrl-Shift-O is for "Organize imports" and it is used to automatically re-arrange your existing imports. Sometimes this might result in adding an import for a class that you have already fully qualified in your code, but that's not the primary purpose of that function.

Jeremy Hunt
  • 701
  • 3
  • 10
  • Eclipse 2021-09 filters out the java.awt imports, so this doesn't work. – greg-449 Oct 17 '21 at 07:02
  • 1
    Does it? Well I haven't seen that version, and if it does there might be a good reason. But on most versions you can check Preferences > Java > Appearance > Type Filters. – Jeremy Hunt Oct 17 '21 at 07:39