bonsoir tout le monde

je vous demande comment ajouter jmenuitem sur JToolBar

par exemple si je click sur le bouton de JToolBar alors un menu s'ouvre
voilla le code

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
 
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.JToolBar;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.Font;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
 
public class menu extends JFrame {
 
	private static final long serialVersionUID = 1L;
 
	private JPanel jContentPane = null;
 
	private JPanel jPanel = null;
 
	private JToolBar jJToolBarBar = null;
 
	private JButton jButton = null;
 
	private JButton jButton1 = null;
 
	private JButton jButton11 = null;
 
 
	private JPanel getJPanel() {
		if (jPanel == null) {
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new Rectangle(10, 15, 565, 216));
			jPanel.add(getJJToolBarBar(), null);
		}
		return jPanel;
	}
 
	private JToolBar getJJToolBarBar() {
		if (jJToolBarBar == null) {
			jJToolBarBar = new JToolBar();
			jJToolBarBar.setBounds(new Rectangle(40, 51, 424, 83));
			jJToolBarBar.setBackground(new Color(0, 138, 255));
			jJToolBarBar.setFloatable(false);
			jJToolBarBar.setOrientation(JToolBar.HORIZONTAL);
			jJToolBarBar.add(getJButton());
			jJToolBarBar.add(getJButton11());
			jJToolBarBar.add(getJButton1());
		}
		return jJToolBarBar;
	}
 
 
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton(new ImageIcon("src/image/NOUVEAU.png"));
			jButton.setFont(new Font("Dialog", Font.BOLD, 14));
			jButton.setText("   ajouter      ");
		}
		return jButton;
	}
 
 
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setFont(new Font("Dialog", Font.BOLD, 12));
			jButton1.setText("  supprimer       ");
			jButton1.setIcon(new ImageIcon(getClass().getResource("/SRC/IMAGE/NOUVEAU.PNG")));
		}
		return jButton1;
	}
 
 
	private JButton getJButton11() {
		if (jButton11 == null) {
			jButton11 = new JButton();
			jButton11.setFont(new Font("Dialog", Font.BOLD, 14));
			jButton11.setText("  modifier     ");
			jButton11.setIcon(new ImageIcon(getClass().getResource("/SRC/IMAGE/NOUVEAU.PNG")));
		}
		return jButton11;
	}
 
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				menu thisClass = new menu();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
			}
		});
	}
 
	public menu() {
		super();
		initialize();
	}
 
	private void initialize() {
		this.setSize(605, 277);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
	}
 
 
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanel(), null);
		}
		return jContentPane;
	}
 
}
merci