Answer the question
In order to leave comments, you need to log in
Compilation error! How to fix?
An error occurred while creating the button click handler. Error while compiling.
Here is my code, everything is written in it, I did it from an online lesson.
package sample;
import javafx.application.Application;
import javafx.event.ActionEvent;
//import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
//import javafx.scene.input.MouseEvent;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application {
public Text question_text;
public Button answerBtn;
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
// root.getChildren().addAll(button);
primaryStage.setTitle("SK exploit");
primaryStage.setScene(new Scene(root, 747, 460));
primaryStage.show();
answerBtn.setOnAction(new ButtonListener());
}
public static void main(String[] args) {
launch(args);
}
class ButtonListener implements EventHandler<ActionEvent> {
@Override
public void handle(ActionEvent activeEvent) {
question_text.setText("Text");
}
}
}
Answer the question
In order to leave comments, you need to log in
@FXML
public Text question_text;
@FXML
public Button answerBtn;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question