Java tutorial
//package com.java2s; //License from project: Open Source License import java.awt.*; public class Main { public static int getCenterX() { return (int) (GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth() / 2); } }