title: How to get the width and height of current monitor in java
body: <p>how to get width and height of screen of current monitor in multimonitor scenarios in java.</p>
  
  <pre><code>GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
      int width = gd.getDisplayMode().getWidth();
      int height = gd.getDisplayMode().getHeight();
  </code></pre>
  
  <p>This piece of code gives the width and height of same monitor even if I run in other monitor.</p>
  
  <p>How do you get the width and height of current monitor. Please help.</p>