Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123741

NPE when removing item from detached Menu

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 8
    • 8
    • javafx
    • None

    Description

      Run this snippet and see an NPE happening:



      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class SimpleApp extends Application {

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

      @Override
      public void start(Stage primaryStage) throws Exception {
      BorderPane p = new BorderPane();
      final MenuBar bar = new MenuBar();
      final Menu m = new Menu("File");
      final MenuItem item = new MenuItem("Hello");
      m.getItems().add(item);
      bar.getMenus().add(m);
      p.setTop(bar);
      Button remove = new Button("Remove");
      remove.setOnAction(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      bar.getMenus().remove(m);
      m.getItems().remove(item);
      }
      });
      p.setCenter(remove);

      primaryStage.setScene(new Scene(p,300,300));
      primaryStage.show();
      }

      }

      Attachments

        Activity

          People

            psomashe Parvathi Somashekar (Inactive)
            tschindl Tom Schindl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: