Bonsoir,
J'ai voulu créer une méthode pour alléger le main, du coup ça ne marche plus,
j'utilise 3 class, j'ai une class pour manipuler des images, une pour faire un menu et la dernière pour le main

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
37
38
39
40
41
import java.io.*;
import java.util.Scanner;
 
public class Bitmap {
    Scanner sc = new Scanner(System.in);
    int[][][]data;
    String nom;
    ImageExterne ie;
    Bitmap(String n) throws IOException, FileNotFoundException {
        this.ie=new ImageExterneLue(n);
        this.nom=n;
        this.data=((ImageExterneLue)ie).getTableau();
    }
    Bitmap(int largeur, int hauteur){
        this.data=new int[largeur][hauteur][3];
        for(int x=0;x<this.data.length;x++){
                    for(int y=0;y<this.data[0].length;y++){
                            this.data[x][y][0]=0;
                            this.data[x][y][1]=255;
                            this.data[x][y][2]=0;
                    }
        }
        this.nom=null;
        this.ie=new ImageExterneCree(this.data);
    }
 
    void ouvrirImage() throws IOException, FileNotFoundException{
    try{
    System.out.println("nom de l'image à ouvrir:");
        String nomImg=sc.nextLine();
        Bitmap varImg=new Bitmap(nomImg);
       }
    catch(FileNotFoundException e){
        System.out.println("Erreur, le fichier n'existe pas!");
    }
    catch(IOException e){
        System.out.println("Ce n'est pas une image!");
     }
    }
 
}
puis mon main

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.*;
import java.util.Scanner;
public class MonTest2Essai2{
    public static void main(String[] args) throws ChoixIncorrect,IOException, FileNotFoundException {
    String [] tabRubriques={"ouvrir une image", "fermer une image","creer une image","incruster une image","sauvegarder une image","afficher la liste des images","quitter le programme"};
    Menu menuUtilisateur=new Menu(tabRubriques);
    int choix=0;
    Bitmap[]mesImages=new Bitmap[3];
    for( int i=0;i<mesImages.length;i++){
       // mesImages[0]=new Bitmap("img1.jpg");
        //mesImages[1]=new Bitmap("coquelicot.jpg");
       // mesImages[2]=new Bitmap("princesse.jpg");
    }
 
    do{
        try{
           choix= menuUtilisateur.afficherChoisir(); //ça marche plus
           switch(choix){
               case 1:mesImages[0].ouvrirImage();
                   break;
              /** case 1: System.out.println("nom du fichier à ouvrir:"); ça marche
               try{
                    mesImages[0]=new Bitmap(sc.nextLine());
               }
               catch(FileNotFoundException e){
                    System.out.println("Erreur, le fichier n'existe pas");
               }
               catch(IOException e){
                    System.out.println("pas une image");
               }
               break;**/
               case 2:System.out.println("fermer");
               break;
               case 3:System.out.println("creer");
               break;
               case 4:System.out.println("incruster une image");
               break;
               case 5:System.out.println("sauvegarder");
               break;
               case 6:System.out.println("afficher collection img");
               break;
           }//switch
        }//try
        catch (ChoixIncorrect e){
            System.out.println("Attention mauvaise saisi, recommencez!");
        }
    }
    while(choix!=7);
 
}//main
}//monTest2
dans le main

Code : Sélectionner tout - Visualiser dans une fenêtre à part
 Bitmap[]mesImages=new Bitmap[3];
Code : Sélectionner tout - Visualiser dans une fenêtre à part
case 1:mesImages[0].ouvrirImage();
j'ai bien déclaré mon objet tableau mesImages de type Bitmap et dans ma méthode

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
    void ouvrirImage() throws IOException, FileNotFoundException{
    try{
    System.out.println("nom de l'image à ouvrir:");
        String nomImg=sc.nextLine();
        Bitmap varImg=new Bitmap(nomImg);
       }
je lui demande bien de créer un objet varImg de type Bitmap avec le nom en paramètre!

aurais-je oublié un truc?

Merci