2

I need the resolution of my screen for my project.

I have already tried the Toolkit.getDefaultToolkit().getScreenSize() function but it does not returns the native resolution because of the Windows's auto scale. My screen resolution is 1920x1080 but it only returns 1536x864.

screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
//it returns 1536x864
Dónal Boyle
  • 3,049
  • 2
  • 25
  • 40
can
  • 309
  • 1
  • 4
  • 13
  • 2
    It looks like this has been answered before: https://stackoverflow.com/questions/3680221/how-can-i-get-screen-resolution-in-java – Dónal Boyle Mar 31 '19 at 19:35
  • 1
    thanks GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); int width = gd.getDisplayMode().getWidth(); int height = gd.getDisplayMode().getHeight(); is solved my problem – can Mar 31 '19 at 19:44

0 Answers0