Skip to content

Instantly share code, notes, and snippets.

@erikgunawan
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikgunawan/ff505865b22c3e4f2eb6 to your computer and use it in GitHub Desktop.
Save erikgunawan/ff505865b22c3e4f2eb6 to your computer and use it in GitHub Desktop.
Mendapatkan Ukuran / Dimensi Layar menggunakan Java
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
/**
* @Developer : Erik Gunawan
* @Nickname : EXz
* @Phone : 0896 5332 0577
* @EMail : admin@erikgunawan.com
* @Gmail : erik.gunawan44@gmail.com
* @Website : www.erikgunawan.com
* @Facebook : facebook.com/revolutionist.exz
* @Twitter : twitter.com/_EXz
*/
public class UkuranLayar {
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice defaultScreenDevice = ge.getDefaultScreenDevice();
GraphicsConfiguration[] gc = defaultScreenDevice.getConfigurations();
Rectangle gcBounds = gc[0].getBounds();
System.out.println("Dimensi Layar:" + gcBounds.getWidth() + " x " + gcBounds.getHeight());
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment