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

Conflict with MenuButton and Menu / graphic disappears


    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: fx2.1
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      Windows 7, JavaFX 2.1 beta b12


      The graphic of a MenuItem disappears if there are several Menus, which share the same MenuItems. In my use case I have to share them among a Menu and a MenuButton. (both menus' items should always have the same state and so on, e.g. selected, text, graphic, action.)

      To reproduce, run the code below. Click on "Menu", then click on "Button", then click on "Menu" again. Notice that the red buttons are no longer displayed in the "Menu", (but are still displayed in the "Button").

      It also works the other way round, if you first click "Button", then "Menu", then "Button".

      It also works, if you use a second MenuButton instead of a MenuBar.

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TestApp3 extends Application {
          public static void main(String[] args) throws Exception {

          public void start(final Stage stage) throws Exception {

              VBox root = new VBox();

              MenuBar menuBar = new MenuBar();
              Menu menu = new Menu("Menu");


              MenuButton menuButton = new MenuButton("Button");

              for (int i = 0; i < 5; i++) {
                  MenuItem menuItem = new RadioMenuItem("MenuItem" + i);
                  Button button = new Button("x");
                  button.setStyle("-fx-background-color: red;");


              root.getChildren().addAll(menuBar, menuButton);
              Scene scene = new Scene(root);


          Issue Links



              • Assignee:
                leifs Leif Samuelsson (Inactive)
                cschudtjfx Christian Schudt (Inactive)
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: