Boa tarde pessoal, consegui fazer meu JFrame ficar no meio da tela com umas dicas que vi aqui no forum, porem quando abro os JDialogs…eles vao la pra cima…alguma luz…to fazendo um projetinho SWing JPA+Hibernate…sao so 5 telas…alguma luz…só ta faltando isso…
Já tentou usar
JDialog.setLocationRelativeTo(null);
JDialog.setVisible(true);
já…e nao funcionou…
usei um codigo que centraliza a tela principal…ficou show de bola…mas as telas abertas em seguida vao la pra cima…e se eu usa r o mesmo cosido para centralizar ele fica mais abaixo do centro e mais a direita :s…
Veja se isso funciona:
// Get the size of the screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
// Determine the new location of the window
int w = window.getSize().width;
int h = window.getSize().height;
int x = (dim.width-w)/2;
int y = (dim.height-h)/2;
// Move the window
window.setLocation(x, y);
fonte: http://exampledepot.com/egs/java.awt/screen_CenterScreen.html
show de bola…funcionou…valews