Bonsoir,

J'ai besoin de votre aide...cela fait des jours que je cherche pour exporter mon fichier java sous eclipse...avec des images...mais quand j'exécute mon fichier jar (qui contient les images) celles-çi n'apparaissent pas.

Qui pourrait m'expliquer mon erreur (ou mes erreurs), svp?

Merci pour votre aide...
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class Main {
    // ====================DECLARATION ET
    // INITIALISATION===========================//
    static private JTextField pourcentage = new JTextField(30);
    static private JTextField essai = new JTextField(20);
    static private int score;
    static private int total;
    static private JButton btnMore = new JButton(new ImageIcon("ok.png"));
    static private JButton btnLess = new JButton(new ImageIcon("no.png"));
    static private JButton reInitialize = new JButton("Remettre à zéro");
    static private JButton closeFrame = new JButton("QUITTER");
 
    public static void main(String[] args) {
        // =====================MISE EN FORME DE LA
        // FENETRE==========================//
        JFrame frame = new JFrame();
        frame.setVisible(true);
        frame.setTitle("EPS COMPTEUR - LYCEE FENELON");
        frame.setSize(800, 600);
        frame.setResizable(true);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // =================================================================//
        // ======================FOND ECRAN============================//
        JPanel content = new ImagePanel(new ImageIcon("fond.png").getImage());
        // =================================================================//
        // ======================AJOUT PANNEAU DANS LA
        // FENETRE==============================//
        frame.setContentPane(content);
        // =================================================================//
        // ======================CHOIX TAILLE ET POLICE DU
        // JLABEL==============================//
        Font f = new Font("Serif", Font.PLAIN, 36); // par exemple
        essai.setFont(f);
        pourcentage.setFont(f);
        Font ft = new Font("Serif", Font.PLAIN, 40 );
        reInitialize.setFont(ft);
        closeFrame.setFont(ft);
        // =================================================================//
        // ============MISE EN FORME DES BOUTONS MISE A ZERO ET
        // QUITTER============================//
        essai.setBackground(Color.YELLOW);
        essai.setBorder(null);
        pourcentage.setBackground(Color.YELLOW);
        pourcentage.setBorder(null);
        // =================================================================//
        // ======================AJOUT DES ELEMENTS AU PANNEAU============================//
 
        content.add(btnMore);
        content.add(btnLess);
        content.add(essai);
        content.add(pourcentage);
        content.add(reInitialize);
        content.add(closeFrame);
        // =================================================================//
        // =====================AFFICHAGE ICONE COIN DE
        // FENETRE=======================//
        frame.setIconImage(new ImageIcon("icon_splash_background.png").getImage());
        // =================================================================//
        // ==============EVENEMENT EN CAS DE CLIC SUR BOUTON
        // OK==========================//
        btnMore.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // quand on a cliqué sur le bouton ici
                score++;
                total++;
                updateLabel();
                updateLabelTry();
 
            }
        });
        // =================================================================//
        // ============EVENEMENT EN CAS DE CLIC SUR BOUTON
        // NO============================//
        btnLess.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // quand on a cliqué sur le bouton ici
                total++;
                updateLabel();
                updateLabelTry();
            }
        });
        // =================================================================//
        // ==========EVENEMENT EN CAS DE CLIC SUR BOUTON
        // QUITTER============================//
        closeFrame.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == closeFrame) {
                    frame.dispose();
                }
            }
        });
        // ===============================================================================//
        // ==================EVENEMENT EN CAS DE CLIC SUR BOUTON MISE A
        // ZERO==============//
        reInitialize.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == reInitialize) {
                    score = 0;
                    total = 0;
                    pourcentage.setText(" ");
                    essai.setText(" ");
                }
            }
        });
    }
 
    // =================================================================//
    // ===============FONCTION POURCENTAGE=========================//
    private static double getAverage() {
        try {
            return 100 * score / total;
        } catch (ArithmeticException e) {
            return 0;
        }
    }
 
    // =================================================================//
    // ===============FONCTION MISE A JOUR DU TEXTE
    // POURCENTAGE==============================//
    private static void updateLabel() {
        pourcentage.setText("Taux de réussite : " + Double.toString(getAverage()) + " %");
    }
 
    // =================================================================//
    // ==============FONCTION MISE A JOUR DU TEXTE NB
    // ESSAI=====================//
    private static void updateLabelTry() {
        essai.setText("Essai : " + score + " / " + total);
    }
 
    /*
     * Classe image background
     */
    static class ImagePanel extends JPanel {
 
        private static final long serialVersionUID = 1L;
        private Image img;
 
        public ImagePanel(String img) {
            this(new ImageIcon(img).getImage());
        }
 
        public ImagePanel(Image img) {
            this.img = img;
        }
 
        public void paintComponent(Graphics g) {
            g.drawImage(img, 0, 0, null);
        }
        /*
         * ====================================================
         */
 
    }
}