package util; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; public abstract class GuiOrganizer { /* receive GUI, set it to center of the screen */ public static void centerGUI(Window gui) { Dimension dm = Toolkit.getDefaultToolkit().getScreenSize(); double width = dm.getWidth(); double height = dm.getHeight(); double xPosition = (width / 2 - gui.getWidth() / 2); double yPosition = (height / 2 - gui.getHeight() / 2); gui.setLocation((int) xPosition, (int) yPosition); } }