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

MenuButton doesn't unhook it's MousePressed and MouseReleased listener on dispose

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: emb-8u6, 8u20
    • Component/s: javafx
    • Labels:

      Description

      Run this code and you will get an exception complaining that the behavior is null. This is because the old skin is still getting the mouse event after it has been disposed.

          @Override
          public void start(Stage stage) throws Exception {

              final MenuButton control = new MenuButton("Click Me!");
              control.getItems().addAll(new MenuItem("one"), new MenuItem("Two"));

              control.skinProperty().addListener((observable, oldValue, newValue) -> System.out.println("new skin: " + newValue.getClass().getName()));

              control.setSkin(new MenuButtonSkin(control) {});
              control.setSkin(new MenuButtonSkin(control));
              final VBox root = new VBox(control);

              Scene scene = new Scene(root, 400, 300);
              stage.setScene(scene);
              stage.show();
          }

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            dgrieve David Grieve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: