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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u20
    • 8u5
    • javafx
    • Mac OS X Mavericks with all the latest of everything on a Mac Pro 2013

      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.

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

              Created:
              Updated:
              Resolved:
              Imported: