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

ContextMenu shown at wrong position on Windows10 with Extended Screen

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u92, 9
    • Fix Version/s: 9
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Backports

        Description

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

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [version 10.0.10586]

        A DESCRIPTION OF THE PROBLEM :
        On windows10, on extended screen mode, contextMenu is displayed at wrong position depending if main Javafx Window is on primary or secondary screen.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1) Run the attach example on a Windows10 computer with 2 screen.

        2) Right click on label

        Depending if the main JavaFX windows is on primary or secondary screen, the contextMenu will be displayed next to mouse position or not.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        ContextMenu should always be displayed close to mouse position!

        Same program works fine on Windows7 and 8.
        ACTUAL -
        I can send a screenshot if you ask me.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        /*
         * To change this license header, choose License Headers in Project Properties.
         * To change this template file, choose Tools | Templates
         * and open the template in the editor.
         */
        package contextmenubug;

        import javafx.application.Application;
        import javafx.event.ActionEvent;
        import javafx.scene.Scene;
        import javafx.scene.control.ContextMenu;
        import javafx.scene.control.Label;
        import javafx.scene.control.MenuItem;
        import javafx.scene.layout.StackPane;
        import javafx.stage.Stage;

        /**
         *
         * @author Daniel
         */
        public class ContextMenuBug extends Application {
            
            @Override
            public void start(Stage primaryStage) {
                Label btn = new Label();
                btn.setText("ContextMenuBug fail on windows10 with extended screen");
                
                MenuItem menuItem = new MenuItem("click on me, blablablblblbalbla");
                menuItem.setOnAction((ActionEvent event) -> {
                    System.out.println("Hello World!");
                });
                ContextMenu contextMenu = new ContextMenu(menuItem);
        // contextMenu.setAutoFix(false);
                btn.setContextMenu(contextMenu);
                
                StackPane root = new StackPane();
                root.getChildren().add(btn);
                
                Scene scene = new Scene(root);
                primaryStage.sizeToScene();
                
                primaryStage.setTitle("ContextMenuBug!");
                primaryStage.setScene(scene);
                primaryStage.show();
            }

            /**
             * @param args the command line arguments
             */
            public static void main(String[] args) {
                launch(args);
            }
            
        }

        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  flar Jim Graham
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: