Java examples for Swing:Screen
center Component On Screen
//package com.java2s; import java.awt.*; public class Main { public static void centerComponentOnScreen(Component c) { // Gre der eingestellten Bildschirmaufl?sung. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double width = screenSize.getWidth(); double height = screenSize.getHeight(); // Gre des <code>JFrame</code>. Dimension size = c.getSize(); width -= size.getWidth();/*from www .j av a 2s .co m*/ height -= size.getHeight(); c.setLocation((int) width / 2, (int) height / 2); } }