protected void center(){
  Container parent=getParent();
  final Dimension size=getPreferredSize();
  setBounds((parent.getWidth() - size.width) / 2,(parent.getHeight() - size.height) / 2,size.width,size.height);
}

protected void center ( ) { Container parent = getParent ( ) ; final Dimension size = getPreferredSize ( ) ; setBounds ( ( parent . getWidth ( ) - size . width ) / 2 , ( parent . getHeight ( ) - size . height ) / 2 , size . width , size . height ) ; }
center the window within the parent component .
