Details
-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
Java 8u-dev repo tip, Linux
Description
I believe the fix for RT-37022 has caused a regression of issue RT-37021. Below is the same test class which run with the changeset for RT-37022 exhibits the same behaviour again of firing once for each time the menu has been shown.
*********************************************** Test Class **********************************************************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class CustomMenuItemTest extends Application {
@Override public void start(final Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(350);
primaryStage.setWidth(500);
CustomMenuItem item = new CustomMenuItem(new Label("Testing"));
item.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
System.out.println("testing fired!");
}
});
final Menu submenu = new Menu("Sub Menu");
submenu.getItems().add(item);
Menu topMenu = new Menu("Top Menu");
topMenu.getItems().add(submenu);
MenuBar menuBar = new MenuBar();
menuBar.getMenus().add(topMenu);
BorderPane pane = new BorderPane();
pane.setTop(menuBar);
primaryStage.setScene( new Scene( pane ) );
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
*********************************************** Test Class **********************************************************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class CustomMenuItemTest extends Application {
@Override public void start(final Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(350);
primaryStage.setWidth(500);
CustomMenuItem item = new CustomMenuItem(new Label("Testing"));
item.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
System.out.println("testing fired!");
}
});
final Menu submenu = new Menu("Sub Menu");
submenu.getItems().add(item);
Menu topMenu = new Menu("Top Menu");
topMenu.getItems().add(submenu);
MenuBar menuBar = new MenuBar();
menuBar.getMenus().add(topMenu);
BorderPane pane = new BorderPane();
pane.setTop(menuBar);
primaryStage.setScene( new Scene( pane ) );
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}