Il tuo codice dovrebbe avere questa struttura:
codice:
public class AddFrame extends JDialog {
//costruttore
//public addFrame(JFrame owner) {
super(owner, true); //Chiamo il costruttore della superclasse dicendogli che la finestra
//sara' modale(secondo parametro a true)
RESTO DEL CODICE DEL COSTRUTTORE
}
RESTO DEL CODICE DELLA CLASSE
}
Nell'actionListener del frame principale:
codice:
if (e.getSource.equals(insert)){
addframe=new AddFrame(this);
}
Nell'actionListener di addFrame:
codice:
if (e.getSource.equals(cancel)){
this.dispose();
}