While using eclipse IDE and learning javafx8 I am getting errors right in the IDE. The first few apps compiled (with errors) and executed but now I can't even get them to execute.
example error msg:
Access restriction: The method 'FlowPane.setAlignment(Pos)' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/jfxrt.jar')
My code: (Yeah it's beginner code but I'm a student so any help is appreciated);
It's almost as if it can't connect with the libraries. Almost every line of actual code is an error - minor but still an error and all the error messages are similar to the one above. Any help is appreciated!!! Thanks!!!
import javafx.application.*;
import javafx.scene.*;
import javafx.stage.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.event.*;
import javafx.geometry.*;
public class JavaFXEventDemo extends Application {
Label response;
public static void main(String[] args) {
//System.out.println("Launching JavaFX application.");
launch(args);
}
public void start(Stage myStage) {
System.out.println("Inside the start() method.");
// give the stage a title
//myStage.setTitle("Introducing Java Buttons and Events");
FlowPane rootNode = new FlowPane(10,10);
// center the controls in the scene
//System.out.println("Here we are.");
rootNode.setAlignment(Pos.CENTER);
// create a scene
Scene myScene = new Scene(rootNode, 300, 100);
// set the scene on the stage
myStage.setScene(myScene);
// create a label
Label myLabel = new Label("Click a button");
// create two push buttons
Button btnFirst = new Button("First");
Button btnSecond = new Button("Second");
// Handle the action events for the first button
btnFirst.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent ae) {
response.setText("First button was pressed.");
}
});
// Handle the action events for the second button
btnFirst.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent ae) {
response.setText("Second button was pressed.");
}
});
// add the label and buttons to the scene graph
rootNode.getChildren().addAll(btnFirst, btnSecond, response);
// show the stage and its scene
myStage.show();
}