import java.awt.*;
int width=0;
int height=0;
width=Toolkit.getDefaultToolkit().getScreenSize().width;
height=Toolkit.getDefaultToolkit().getScreenSize().height;
frame.setLocation((width - frameSize.width) / 2, (height - frameSize.height) / 2);
frame.setVisible(true);