Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

In JavaFX and scenebuilder project, how to use the setOnAction() method in Controller class

I am new to JavaFX and SceneBuilder.
I created an app using the SceneBuilder in Eclipse. (Right click FXML file > open with SceneBuilder)
Inside initialize method, I can not see the setOnAction method.

enter image description here

package application.controller;

import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.scene.image.ImageView;

public class controller {

    

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;

    @FXML
    private JFXTextField loginID;

    @FXML
    private JFXPasswordField passwordID;

    @FXML
    private ImageView loginButton;

    @FXML
    public void initialize() {
        loginButton.setona
        
    }
    
    
    
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You defined loginButton as an ImageView. ImageView does not have setOnAction method. use setOnMouseClicked instead.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading