Bonjour,
je rencontre un probleme avec mes evenement souris :s ils ne s'éxécute pas ...
et aussi j'aimerai connaitre la meilleur methode pour attribuer un identifiant a mon bouton, dans ma classe JButton j'ai trouvé la méthode .setMnemonic.
voici mon code :
merci d'avance,
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 import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Vector; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; public class int_fenConfiguration extends JFrame implements ActionListener { int JP_fenConfiguration_sizeY=40; configuration CL_config; JButton JB_add ; JButton JB_del ; JButton JB_set ; JLabel JL_nom; JPanel JP_fenConfiguration; int I_ligne; int I_colonne; String S_nomCellule; public int_fenConfiguration () { JP_fenConfiguration = new JPanel(); JB_add = new JButton(new ImageIcon("img/BT_add.png" )); JB_del = new JButton(new ImageIcon("img/BT_del.png" )); JB_set = new JButton(new ImageIcon("img/BT_set.png" )); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); CL_config = new configuration(); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); CL_config.nom.add("laurent"); for (int i=0 ; i < CL_config.nom.size() ; i++) { JL_nom = new JLabel(CL_config.nom.elementAt(i).toString()); JL_nom.setPreferredSize(new Dimension(100,20)); JB_set = new JButton(new ImageIcon("img/BT_set.png" )); JB_set.setMnemonic(i); JB_set.addActionListener(this); JB_del = new JButton(new ImageIcon("img/BT_del.png" )); JB_del.setMnemonic(i); JB_del.addActionListener(this); JP_fenConfiguration.add(JB_set); JP_fenConfiguration.add(JL_nom); JP_fenConfiguration.add(JB_set); JP_fenConfiguration.add(JB_del); JP_fenConfiguration_sizeY+=30; }; this.setSize(250, JP_fenConfiguration_sizeY); this.setContentPane(JP_fenConfiguration); this.setResizable(false); this.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource() == JB_set) { System.out.print("hello"); } } }
Cordialement.
Partager