Bonjour tout le monde.
Me voila en train de basculer vers le java et j'aimerais avoir un coup de patte sur un point précis.
A force de tutoriel, de gratter, j'ai réussi à changer le nom de la form que j'ai dessiné depuis le code. Cependant, j'aimerais changer la petite icône en haut et à gauche, juste avant le nom. J'ai essayer plusieurs méthode mais à priori ça ne s'exécute pas.
Voila ce que j'ai fait comme code, pardonnez-moi si c'est loin d'être parfait. Débutant oblige.
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
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
/*
 * Form1.java
 *
 * Created on 4 juil. 2009, 20:33:20
 */
package testapi2;
 
import java.awt.Image;
 
/**
 *
 * @author Alexandre
 */
public class Form1 extends javax.swing.JFrame {
 
 
    /** Creates new form Form1 */
    public Form1() {
        initComponents();
    }
 
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
 
        jSeparator1 = new javax.swing.JSeparator();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setForeground(java.awt.Color.white);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });
 
        jMenu1.setText("Fichier");
 
        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/testapi2/Ressources/Icônes 16x16/Fichier.png"))); // NOI18N
        jMenuItem1.setText("Ouvrir");
        jMenu1.add(jMenuItem1);
        jMenu1.add(jSeparator2);
 
        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/testapi2/Ressources/Icônes 16x16/Non.png"))); // NOI18N
        jMenuItem2.setText("Quitter");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);
 
        jMenuBar1.add(jMenu1);
 
        jMenu2.setText("Edit");
        jMenu2.setEnabled(false);
        jMenuBar1.add(jMenu2);
 
        setJMenuBar(jMenuBar1);
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(198, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
 
        pack();
    }// </editor-fold>                        
 
    //Si on appuie sur le bouton fermer dans le menu
    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // Ferme l'application
        this.dispose();
    }                                          
 
    //A l'ouverture de la boite de dialogue
    private void formWindowActivated(java.awt.event.WindowEvent evt) {                                     
        // On change le texte
        this.setTitle("Test par Microbulle");
        this.setIconImage(null); // <- C'est ici que je cherche à récupérer l'image de mon icône et qui à pour chemin : /testapi2/Ressources/Icônes 16x16/épée.png
    }                                    
 
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Form1().setVisible(true);
            }
        });
    }
 
    // Variables declaration - do not modify                     
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    // End of variables declaration                   
 
 
}
Comment est-il possible de changer cela ?
Merci beaucoup pour votre aide.
Cordialement.