Home:ALL Converter>Error in menus in Java FX

Error in menus in Java FX

Ask Time:2013-10-14T23:24:16         Author:Ankur Saha

Json Formatter

I am new to JavaFX using Netbeans 7.3.1 and currently working with Menus. I am reading the book "java Fx 2.0 Introduction by example" and was trying out the menu example in the book when i faced the following error..

constructor Menu in class Menu cannot be applied to given types;
required: no arguments
found: String
reason: actual and formal argument lists differ in length

Here is my code, it is correct as far as my JavaFx knowledge is concerned and have included all major java FX Menu imports!! I dunno why the "Menu" constructor won't take in string as parameters!! Please help!!

package menu;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.stage.Stage;
public class Menu extends Application {

    @Override
    public void start(Stage primaryStage) {
        Group root = new Group();
        Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");
        MenuBar menuBar = new MenuBar();
        Menu menu = new Menu("File");//This line is giving errors..
        menu.getItems().add(new MenuItem("New"));
        menu.getItems().add(new MenuItem("Save"));
        menu.getItems().add(new SeparatorMenuItem());
        menu.getItems().add(new MenuItem("Exit"));
        menuBar.getMenus().add(menu);
        root.getChildren().add(menuBar);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Author:Ankur Saha,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19363656/error-in-menus-in-java-fx
yy