Why does the IDE recognize some imports and not others?
Hello,
I have the following problem. I'm importing the following (among other things) into my class:
import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode;
And now my IDE tells me that KeyEvent works without issues, but KeyCode doesn't. It just can't find it. The strange thing is: When I run my code, KeyCode works, no errors appear, and the functionality works as intended – it just displays an error in the IDE.
Maybe someone has an idea that would be great, thanks.
Sounds like an indexing problem or the project settings in IntelliJ
Does that also explain why only some imports work? I think it's weird, it comes from the same package.
Of course, it's strange that only a part of it works, but there are many steps you could do to fix it.
Inconsistent indexing, caching problems, partial library integration, class loader problem, IDE bending of only certain classes.
Try manual reloading of the class, check the module dependencies, importer = import javafx.scene.input.KeyCode;
Clean and Rebuild and finally check the .iml file if there is and see if all JavaFX related entries are correct.
I have now explicitly indicated the specific package in addition to the dependencies, now it shows the IDE correctly.
Which IDE do you use?
IntelliJ
If you want to shoot yourself in your leg, you can try it with Eclipse … is probably the worst IDE but with me the most worked 😄
Are methods of the class concerned used in the source code itself?
InteliJ IDEA (stands in tags)
OK.
I have now explicitly indicated the specific package in addition to the dependencies, now it shows the IDE correctly.
Did you restart the IDE?
You mean if the JavaFX files are specified in the Dependencies? Yeah.
Is the import in question also in dependence?
He shows the mistake in the import, yes. But only with KeyCode, not KeyEvent, which is imported from the same package. The paths to the modules are known, yes.
And this mistake arises in the import directives? Are the IDE known the paths to the modules?
More often, in fact:/
As I said, when performing there is no mistake. Only at Hovern via KeyCode it shows the following: "Cannot resolve symbol 'KeyCode'"
What is the IDE error message?
Yes, here:
private void handleKeyPress(KeyEvent event, ArrayList
KeyCode = event.getCode();
….
}