Java examples for Swing:JWindow
set JWindow JFrame Center
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JWindow; public class Main { public static void setCenter(JWindow win) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); win.setLocation((d.width - win.getWidth()) / 2, (d.height - win.getHeight()) / 2); }/* w w w . j a v a 2 s.c o m*/ public static void setCenter(JFrame frame) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2); } }