Fermer une fenetre sous java
melaine
-
melaine -
melaine -
Je voudrais fermer une JFrame définitivement sans utiliser les 3 icones en haut à droite de la fenetre mais en utilisant une commande et ce sans quitter le programme qui est cours d'éxecution derrière.
Quelle commande utiliser
la cde dispose ne ferme pas définitivement la fenetre !!!
system.exit(0) ferme totalement toutes les applications lancées !!!
merci
Melaine
Quelle commande utiliser
la cde dispose ne ferme pas définitivement la fenetre !!!
system.exit(0) ferme totalement toutes les applications lancées !!!
merci
Melaine
A voir également:
- Fermer une fenetre sous java
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Waptrick java voiture - Télécharger - Jeux vidéo
- Eclipse java - Télécharger - Langages
- Java apk - Télécharger - Langages
1 réponse
Salut, utilise ceci
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE).
ou alors setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE).
ou encore (et c'est même mieux)
//dans le constructeur
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
exitForm();
}
}
);
//
private void exitForm() {
if(JOptionPane.showConfirmDialog(null,"Do you really want to close the configuration ?","Question",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE)==0){
this.setVisible(false);
}
}
}
Chouba
"I want to be Oo Minded"
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE).
ou alors setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE).
ou encore (et c'est même mieux)
//dans le constructeur
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
exitForm();
}
}
);
//
private void exitForm() {
if(JOptionPane.showConfirmDialog(null,"Do you really want to close the configuration ?","Question",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE)==0){
this.setVisible(false);
}
}
}
Chouba
"I want to be Oo Minded"
melaine
thanks