Koser
Koser

Reputation: 11

'@FXML' not applicable to type

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

Answers (2)

0009laH
0009laH

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

Mayur Patel
Mayur Patel

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

Related Questions