Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Hani Ibrahim
Added: Nov 9, 2018 9:54 AM
Views: 3
Draw jFrame in the center of the screen
  1.         // Calculate screen-centered windows position
  2.         final Dimension d = this.getToolkit().getScreenSize();
  3.         int win_x = (int) ((d.getWidth() - this.getWidth()) / 2);
  4.         int win_y = (int) ((d.getHeight() - this.getHeight()) / 2);
  5.         // Set window position
  6.         setLocation(win_x, win_y);