I am trying to get some practice in with javaFX, and I just wanted to see if I could get a simple button to be created and prepared with a setOnAction enabled. However, the btn does not have the .setText method aand the EventHandler gives an error on ActionEvent saying that ActionEvent is not bound and should extend Event.
I am following countless tutorials and this should be what everyone is doing for their buttonsetup, but it is falling apart. I am using 1.7_45, so JavaFX is supported. I also enabled the JavaFX support plugin in IDEA.
//package ;
import javafx.*;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class OptionsToggleMenu {
public OptionsToggleMenu() {
}
public void launch(String... args){
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World!");
final Button btn = new Button();
btn.setText("hello world");
//btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
btn.setText("changed");
}
});
}
}