-
Bug
-
Resolution: Fixed
-
P4
-
8
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();
}
@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();
}