galera é o seguinte possuo um JFrame principal em minha aplicação, tenho um Jmenu e neste menu tem lah “cadastro”, bom quando clicar em "cadastro ele cria um outro JFrame com a tela de “cadastro”, para esta tela eu testei tanto com o JFrame quanto com um JDialog, eu gostei mais do JDialog pq no momento que vc abre, a aplicação trava as janelas e vc soh fica focado na janela que foi aberta, não podendo voltar a tela do principal, apenas se vc fechar o JDialog assim liberando para voltar no principal.
ja o Jframe quando vc abre a janela de cadastro, vc pode ficar alterando entre as janelas.
bom gostaria de saber se é possivel travar as janelas e colocar uma em focus, igual o que o JDialog faz, mas utilizando um Jframe???
se vcs testarem entederam do que eu estou falando, atravez de um Jrame chamem outras 2 janelas 1 Jframe e 1 JDialog, vcs veram a diferença ao tentar voltar para a janela principal.
Valeu!!!
Não existe o método modal(true) para o JFrame, igual ao do JDialog.
Jóia pessoal?
Minha primeira dúvida (e primeiro post) está relacionada à pergunta feita pelo colega “shakall”.
Quer dizer que não existe a possibilidade de trabalharmos com 1 jFrame “chamando” outro jFrame, mas mantendo apenas 1 sendo exibido?
Digo: como se o primeiro jFrame ficasse “invisível” enquanto o segundo permanecesse ativo. Após concluirmos a “tarefa” no segundo, o primeiro “voltaria” a ficar visível.
Se isto for possível, e se alguém tiver algum exemplo, por favor nos ajude!
Abraço, e obrigado! 
Olá learning_java,
se entendi o que você quer, fiz um exemplo bem prático e simples…
Classe1.java
/*
* Classe1.java
*
* Created on 4 de Setembro de 2007, 17:42
*/
/**
*
* @author sergio
*/
public class Classe1 extends javax.swing.JFrame {
/** Creates new form Classe1 */
public Classe1() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
getContentPane().setLayout(null);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("Chama janela2");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(110, 120, 150, 60);
jLabel1.setFont(new java.awt.Font("Dialog", 1, 24));
jLabel1.setText("Janela 1");
getContentPane().add(jLabel1);
jLabel1.setBounds(130, 70, 190, 40);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new Classe2().setVisible(true);
this.setVisible(false);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Classe1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
Classe2.java
[code]/*
- Classe2.java
-
- Created on 4 de Setembro de 2007, 17:44
*/
/**
*
-
@author sergio
*/
public class Classe2 extends javax.swing.JFrame {
/** Creates new form Classe2 */
public Classe2() {
initComponents();
}
/** This method is called from within the constructor to
-
initialize the form.
-
WARNING: Do NOT modify this code. The content of this method is
-
always regenerated by the Form Editor.
*/
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
getContentPane().setLayout(null);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font(“Dialog”, 1, 24));
jLabel1.setText(“Janela2”);
getContentPane().add(jLabel1);
jLabel1.setBounds(140, 110, 100, 30);
jButton1.setText(“Janela 1 novamente…”);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(100, 150, 200, 70);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-406)/2, (screenSize.height-296)/2, 406, 296);
}//
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new Classe1().setVisible(true);
}
/**
-
@param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Classe2().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
[/code]
Testa ae e poste suas dúvidas.
Um abraço!
Muito obrigado serjaum!!!
Está muito próximo do que eu preciso.
Vou estudar direitinho o que tu escreveu e colocar pra funcionar no meu código!
Abraço!

P.S. - uma dúvida: qual IDE você utiliza?
Ola learning_java,
utilizei o NetBeans pra criar as interfaces.
É neste trecho que você dever colocar o código que será executado quando o botão for pressionado:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new Classe2().setVisible(true);
this.setVisible(false);
}
É bem fácil trabalhar com GUI no NetBeans, mas recomendo que você aprenda usando um editor simples como bloco de notas, gedit, etc… Depois que estiver fera, use o NetBeans ou outro para fazer as telas.
Bons estudos e se houver dúvidas, poste-as!
Um abraço!