I am developing an app for which I need the screen DPI.. I checked a few forums and got a code snippet which goes as follows:
Dimension screen = java.awt.Too
this code works for me on win10
import javafx.stage.Screen
double getScaleFactor() {
double trueHorizontalLines = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
double scaledHorizontalLines = Screen.getPrimary().getBounds().getHeight();
double dpiScaleFactor = trueHorizontalLines / scaledHorizontalLines;
return dpiScaleFactor;
}
it uses some awt apis though
The problem is no one, not even the OS, knows the exact physical dimensions of the screen. You'd need to know that in order to calculate the PPI.
There's a display setting in the control panel where the user can manually specify the PPI and by default it's set to 96.