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

Gap between ContextMenu and the anchor Node.

XMLWordPrintable

    • x86
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      OSX 11, Ubuntu 14, Ubuntu 16

      A DESCRIPTION OF THE PROBLEM :
      First show() on ContextMenu seems to not fully apply the css ofthe anchor Node. This results in a gap between the anchor and context menu(see source code example)

      When show is called the a second time the problem is gone.

      As you can see in source code this happens if i have a parent css with a non standard font size set.

      Tested on u66, u74 and u92

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start test case application
      Push button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ContextMenu show be shown just above the button
      ACTUAL -
      ContextMenu is shown above the button with a gap
      The second time you press the button the context menu is shown just above the button(correct behavior)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package contextmeu.bug.example

      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.MenuItem;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class main extends Application {

         public static void main(String[] args) {
             launch(args);
         }

         @Override
         public void start(Stage primaryStage) {
             ContextMenu menu = new ContextMenu();
             menu.getItems().add(new MenuItem("123"));

             Button button = new Button();
             button.setStyle("-fx-font-size: 0.50em;");
             button.setOnAction(event -> menu.show(button, Side.TOP, 0, 0));

             Scene scene = new Scene(new StackPane(button), 800, 800);
             primaryStage.setScene(scene);
             primaryStage.show();
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Calling show() on the menu twice.

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: