Eclipse Autocomplete not Working... Only for AWT? [duplicate]
Asked Answered
R

1

12

The title pretty much explains it.

Autocomplete won't work in Eclipse, but only when I use it on objects related to java.awt. The methods overriden from Object appear, but that's it.

Here's an example

It happens in every project, not one in particular. I've tried reinstalling Eclipse, didn't work. Any help is appreciated.

Reborn answered 10/10, 2021 at 0:24 Comment(2)
No idea. Sorry. But you probably shouldn't be using AWT anymore anyway. It was largely replaced with JFC/Swing. And that was largely replaced by JavaFX. Any particular reason you chose to use AWT?Underskirt
@ElliottFrisch see Dominik's comment on the answer: "Classes defined in package java.awt (like Shape or LayoutManager) are used in Swing-applications as well, so even those which are not programming an AWT GUI might run into this problem"Crump
K
16

awt contains the List class (java.awt.List).

It's an unmitigated disaster, that. 99.9995872858% of the time that you type List and hit autocomplete, you just want eclipse to auto-import java.util.List, instead, until the most recent version, it popped up a non-modal dialog: Did you mean java.awt.List or java.util.List?

Programmers, being their usual lazy/incapable self, whined about this. That was a bit daft of them; there is a trivial setting in eclipse to banlist an entire package, so that it doesn't show up pretty much anywhere: Not in the Open Type dialog, and not in autocompletes. That's the 'Type Filter' feature and it's been around for years.

But programmers decided to continue to whine instead of add the setting.

With that context in mind, this should now make sense:

java.awt.* is now on this banlist by default.

But, you unique snowflake you, you found a time machine or cryosleep capsule, and slept through 20 years of history. Apparently, what other possible explanation could there be that you're still using AWT?

At any rate, simply take java.awt off that banlist and all will be well.

Open your eclipse workspace preferences, type 'Type Filters' in the filterbox. You're looking for setting java > Appearance > Type Filters. Click that, then uncheck java.awt.

Kindig answered 10/10, 2021 at 1:39 Comment(3)
Thanks for this solution! Classes defined in package java.awt (like Shape or LayoutManager) are used in Swing-applications as well, so even those which are not programming an AWT GUI might run into this problem.Caisson
Let's not forget Rectangle, Dimension and so on...Posner
I am also such a snow flake. And java.awt is so mighty, look just at java.awt.Robot. And for swing, you also need base classes as Container. Just to add components to a JFrame. Or add a windowstate listener. So AWT is still very usefull. Even though its old. I am really shocked that they put java.awt onto the ban list just "for fun".Jamila

© 2022 - 2024 — McMap. All rights reserved.