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

ContextMenu sometimes does not render on Linux

XMLWordPrintable

    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      OS: Solus 4.1 Fortitude 64-bit
      JVM: Eclipse OpenJ9 14
      JavaFX 14

      A DESCRIPTION OF THE PROBLEM :
      Given enough clicks of the Button, the sample application sometimes fails to render ContextMenu, however it is still clickable - which this sample code does not exactly illustrate (I can confirm from another application).

      This never happens on Windows.

      Note that I have a relatively low-end laptop should it matter.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just click the button enough times in the sample application under Linux.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The ContextMenu should always display upon button click (when the button is enabled).
      ACTUAL -
      Sometimes, the button is disabled and the ContextMenu is NOT displayed - and the text says "showing".

      I can confirm from my other application that the ContextMenu actually IS there, and it responds to mouse clicks.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.geometry.Side;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ContextMenu;
      import javafx.scene.control.Label;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class Test extends Application {

          @Override
          public void start(Stage primaryStage) {
              primaryStage.setTitle("Hello World!");
              Button btn = new Button();
              btn.setText("Show ContextMenu");

              Label label = new Label();

              ContextMenu ctx = new ContextMenu();
              ctx.getItems().add(new MenuItem("First"));
              ctx.getItems().add(new MenuItem("Second"));
              ctx.getItems().add(new MenuItem("Third"));
              ctx.getItems().add(new MenuItem("Fourth"));
              ctx.getItems().add(new MenuItem("Fifth"));

              ctx.setOnShown(e -> {
                  label.setText("Showing");
              });

              ctx.setOnHidden(e -> {
                  btn.setDisable(false);
                  label.setText("Not showing");
              });

              btn.setOnMouseClicked(ec -> {

                  btn.setDisable(true);

                  ctx.show(btn, Side.BOTTOM, 0.0, 0.0);
              });

              HBox box = new HBox();

              StackPane root = new StackPane();
              root.getChildren().add(box);
              box.getChildren().add(btn);
              box.getChildren().add(label);

              primaryStage.setScene(new Scene(root, 300, 250));
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I know of no workaround.

      FREQUENCY : occasionally


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: