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

Screen.getPrimary().getDpi() returns 0 (zero) DPI on MacBook Pro Retina Boot Camp Windows 10

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • 9
    • 8u74
    • javafx
    • x86
    • other

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


      ADDITIONAL OS VERSION INFORMATION :
       Microsoft Windows [Version 10.0.10586]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      MacBook Pro Retina running Boot Camp

      A DESCRIPTION OF THE PROBLEM :
      Screen.getPrimary().getDpi() returns 0 on MacBook Pro Retina Boot Camp Windows 10.
      Happens on 2 tested MacBook Pros. Repeatable every time.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run a JavaFX Application under JVM 8u74 in a MacBook Pro Retina Boot Camp Windows 10 environment.
      Call Screen.getPrimary().getDpi().

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The method should return the Retina screen's dots per inch, possibly modified by some scaling factor negotiated between Windows 10 and the JVM.
      ACTUAL -
      The method returns 0.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.stage.Screen;
      import javafx.stage.Stage;

      public class DemoBadDpiOnMacRetinaBootCampWindows10 extends Application {

         @Override
         public void start( final Stage primaryStage ) throws Exception {
            System.out.println( "Screen.getPrimary().getDpi(): " + Screen.getPrimary()
                                                                        .getDpi() );
         }

         public static void main( final String[] args ) {
            launch( args );
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Check for an unreasonable value, and if so then fall back to AWT Toolkit.getDefaultToolkit().getScreenResolution().

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

              Created:
              Updated:
              Resolved: