GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
DisplayMode dm = gd.getDisplayMode();
//System.out.println(dm.getWidth()+"x"+dm.getHeight( ));
//setLocation(30, 30);
int posY = dm.getHeight()/2 - dialog.getSize().height/2;
int posX = dm.getWidth()/2 - dialog.getSize().width/2;
dialog.setLocation(posX,posY);