Reputation: 11
package sample;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import java.io.File;
import java.net.URL;
import java.util.ResourceBundle;
import
public class tGenController implements Initializable {
Controller of a fxml
@FXML
//Error appears here says "@FXML" not applicable to type
private class generatePress() {
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
}
}
Error msg pop up on "@FXML" says "@FXML" not applicable type.
I through I did import all the required package but that still doesn't work.
Upvotes: 0
Views: 74
Reputation: 1998
I cannot put a comment as I haven't enough reputation : why does your controller implements Initializable
? Isn't it more convenient for you to use this code instead?
public class tGenController extends [Root] {
// [Root] is the main tag on your FXML file
@FXML
private void generatePress() {
//XXX
}
@FXML
public void initialize() {
//XXX
}
}
Upvotes: 0
Reputation: 339
There is a bit of mistake in your code. I think generatePress() is a function and you have defined it as a class.
Try this in your controller class -
@FXML private void generatePress(){
}
Upvotes: 3