例如:JFrame f = new JFrame();int w = (Toolkit.getDefaultToolkit().getScreenSize().width - width) / 2;int h = (Toolkit.getDefaultToolkit().getScreenSize().height - height) / 2;f.setLocation(w, h);
楼上正解,留个脚印当索引,呵呵