xxxxxxxxxx
import javax.swing.*;
import java.awt.*;
public class JFrameCenterPositionTest extends JFrame {
public JFrameCenterPositionTest() {
setTitle("JFrameCenter Position");
add(new JLabel("JFrame set to center of the screen", SwingConstants.CENTER), BorderLayout.CENTER);
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null); // this method display the JFrame to center position of a screen
setVisible(true);
}
public static void main (String[] args) {
new JFrameCenterPositionTest();
}
}