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

Screen.getPrimary().getDpi() and Toolkit.getDefaultToolkit().getScreenResolution() returns different values

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u5
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Environment:

      Mac OS X Mavericks with all the latest of everything on a Mac Pro 2013

      Description

      Seems like JavaFX and AWT disagrees on the DPI and AWT is correct.
      Note that it's the AWT Toolkit.

      System.out.println(Screen.getPrimary().getDpi());
      System.out.println(Toolkit.getDefaultToolkit().getScreenResolution());

      prints
      72
      101

      on my Mac OS X Mavericks with a 30" Cinema Display.

      AWT seems to return the correct value since that is 100.63 DPI.

      JavaFX also returns 72 for the secondary screen which should be 99.5 DPI.

      The problem with returning the wrong DPI is that you can't make graphics for instance 10 inches wide. And you can't make apps that react to higher density screens.

        Attachments

          Activity

            People

            • Assignee:
              anthony Anthony Petrov (Inactive)
              Reporter:
              mgrev Mikael Grev
            • Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: