Skip to Main Content

Why do I get these error msgs using javafx?

TranceShifterJun 29 2016 — edited Jun 29 2016

               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.");



  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.");


  // create a scene

  Scene myScene = new Scene(rootNode, 300, 100);

  // set the scene on the stage


  // 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;


Post Details
Added on Jun 29 2016
1 comment