1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
private void jBEnregistreActionPerformed(java.awt.event.ActionEvent evt) {
/*Creer FileChooser*/
JFileChooser fc = CtrCacher.ouvrirFileChooser();
int returnVal = fc.showSaveDialog(ResCacherVue.this);
//Si Valider
if ( returnVal == JFileChooser.APPROVE_OPTION){
//Retourne le nom du fichier sélectionné et son path
File file = fc.getSelectedFile();
//si le nom du fichier existe déjà --> demande confirmation
if (file.exists()){
int reponse = JOptionPane.showConfirmDialog (null, "effacer le fichier existant?", "Confirmer la réecriture",JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
}
//récupère le path
String path = file.getPath();
try {
FileOutputStream fichier = new FileOutputStream(path);
ObjectOutputStream objet = new ObjectOutputStream(fichier);
objet.writeObject(jLIResultat.getIcon());
objet.close();
}catch(IOException io){}
}
}
public static JFileChooser ouvrirFileChooser(){
//Creation du filtreChooser.
if (fc == null) {
fc = new JFileChooser();
//Ajout du filtre sélectionnant uniquement les bmp
fc.addChoosableFileFilter(new FiltreImage());
fc.setAcceptAllFileFilterUsed(false);
}
return fc;
} |
Partager