I am trying to learn JavaFX, and I\'ve written the code shown down below, however I seem to be having trouble with this line of code:
btn.setOnAction(new Eve
You have imported awt event listener just change this line of code
import java.awt.event.ActionEvent;
with this
import javafx.event.ActionEvent;
and you can also use lambda expression like this
btn.setOnAction((event) -> {
System.out.println("Button clicked");
});
You're mixing up Javafx with Swing. Replace
import java.awt.event.ActionEvent;
with
import javafx.event.ActionEvent;