public void centerDialog(){
  final Toolkit toolkit=Toolkit.getDefaultToolkit();
  final Dimension screenSize=toolkit.getScreenSize();
  final int x=(screenSize.width - getWidth()) / 2;
  final int y=(screenSize.height - getHeight()) / 2;
  setLocation(x,y);
}

public void centerDialog ( ) { final Toolkit toolkit = Toolkit . getDefaultToolkit ( ) ; final Dimension screenSize = toolkit . getScreenSize ( ) ; final int x = ( screenSize . width - getWidth ( ) ) / 2 ; final int y = ( screenSize . height - getHeight ( ) ) / 2 ; setLocation ( x , y ) ; }
center the dialog on the screen .
