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

Menus offset on high res screens

    XMLWordPrintable

Details

    • x86_64
    • windows

    Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.248]

      A DESCRIPTION OF THE PROBLEM :
      The menus from a MenuBar are offset in some conditions on systems with high res screens.

      I have a system that has 2 identical 4k screens attached, both with 200% scaling. The left screen is screen 2, the right screen is screen 1.

      When an application with a MenuBar is touching the left edge of screen 1, the first menu in the menubar will be offset to the middle of the screen when opened. All other menus are fine.

      When the application is on screen 2, all the menus are misaligned when opened.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached demo
      Move the application to the left edge of screen 1
      Try the menus


      Move the application to the other screen
      Try the menus


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The menus open directly below the menubar item
      ACTUAL -
      The menus open way over to the right

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class MainWindow extends Application
      {
          public static void main(
              String[] args)
          {
              launch(args);
          }

          @Override
          public void start(
              Stage primaryStage) throws Exception
          {
              final Menu fileMenu = new Menu("File");
              fileMenu.getItems().addAll(
                      createItem("Open"),
                      createItem("Save"));
              
              final Menu editMenu = new Menu("Edit");
              editMenu.getItems().addAll(
                      createItem("Copy"),
                      createItem("Paste"));
              
              final BorderPane root = new BorderPane();
              root.setTop(new MenuBar(fileMenu, editMenu));
              
              primaryStage.setScene(new Scene(root, 600, 400));
              primaryStage.show();
          }
          
          private MenuItem createItem(
              final String name)
          {
              final MenuItem item = new MenuItem(name);
              item.setOnAction(e -> System.out.println("User clicked " + name));
              return item;
          }

      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: