Aqui tengo un ejemplo de como centrar un JFrame en la pantalla :
Código PHP:
import javax.swing.JFrame;
public class Prueba{
public static void main(String[] args){
JFrame frame = new JFrame("Prueba JFrame");
frame.setSize(500, 500);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Basicamente lo que hacemos es usar el metodo setLocationRelativeTo
y ponerlo en null.
Si te sirvio de algo comenta