Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaFX: No controller specified for top-level element #347

Closed
Nature711 opened this issue Oct 27, 2021 · 3 comments
Closed

JavaFX: No controller specified for top-level element #347

Nature711 opened this issue Oct 27, 2021 · 3 comments

Comments

@Nature711
Copy link

Nature711 commented Oct 27, 2021

image

When I look into details about the fxml code, I discovered that intellij is giving me warning on all the onAction fields, with the message "No controller is specified for top-level element". But even so the code still works and the proposed functionalities work correctly. So what exact is this problem, and do I need to care about it?

Thanks :D

@Jh123x
Copy link

Jh123x commented Oct 28, 2021

Hi @Nature711, I'm from your senior batch (dropping by in this forum to see if I can help you guys with tech problems)

Have you tried adding your controller to the top level pane.
EG: fx:controller="com.example.Controller"
Can refer to Source for more info

@kouyk
Copy link

kouyk commented Oct 28, 2021

Have you tried adding your controller to the top level pane. EG: fx:controller="com.example.Controller" Can refer to Source for more info

Hi @Nature711, yet another senior here. I won't quite recommend the above solution, because there are two ways to specify the controller, either in the FXML or via code, see this line for how it is specified. Given that there are two ways, it is highly recommended to stick to one, or else conflicts might occur, in this case AB3 and by extension your tP chose to set it via code.

Intellij is probably having troubles picking up this association and hence the warning, but it can be safely disregarded.

@Nature711
Copy link
Author

Ok this resolved the issue, thanks a lot :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants