I'm new to JavaFX and currently having some trouble working with onAction events with classes within different packages.
Here is the package tree :
Here is the sample of code that is not working :
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane fx:controller="GUIController.AccueilController"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
...
<HBox spacing="10" alignment="bottom_right"
GridPane.columnIndex="1" GridPane.rowIndex="4">
<Button text="Se connecter" onAction="#handleSubmitButtonAction"/>
</HBox>
...
</GridPane>
The error is sent by :
onAction="#handleSubmitButtonAction"
Saying : "Handler method is not accessible. Make public, or annotate with @FXML"
Here is the AccueilController.java file :
package GUIController;
import java.awt.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.text.Text;
public class AccueilController {
@FXML private Text actiontarget;
@FXML protected void handleSubmitButtonAction(ActionEvent event) {
actiontarget.setText("Sign in button pressed");
}
}
As you can see, the @FXML tag has been added, so I don't know where the problem is. It may be a bit dumb, but I really can't figure it out.
By the way, without the onAction line, the code is working perfectly.
Thank you guys !