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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
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 JPopupMenu jPopupMenu = null;
private JPopupMenu jPopupMenu1 = null;
private JMenuItem jMenuItem = null;
private JMenuItem jMenuItem1 = null;
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
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;
}
/**
* This method initializes jJToolBarBar
*
* @return javax.swing.JToolBar
*/
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());
jJToolBarBar.add(getJPopupMenu());
}
return jJToolBarBar;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
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 ");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
jPopupMenu.show(jButton, 0, 0);
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.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;
}
/**
* This method initializes jButton11
*
* @return javax.swing.JButton
*/
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;
}
/**
* This method initializes jPopupMenu
*
* @return javax.swing.JPopupMenu
*/
private JPopupMenu getJPopupMenu() {
if (jPopupMenu == null) {
jPopupMenu = new JPopupMenu();
}
return jPopupMenu;
}
/**
* This method initializes jPopupMenu1
*
* @return javax.swing.JPopupMenu
*/
private JPopupMenu getJPopupMenu1() {
if (jPopupMenu1 == null) {
jPopupMenu1 = new JPopupMenu();
jPopupMenu1.add(getJMenuItem());
jPopupMenu1.add(getJMenuItem1());
jPopupMenu.add(new JMenuItem("1"));
jPopupMenu.add(new JMenuItem("2"));
}
return jPopupMenu1;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem() {
if (jMenuItem == null) {
jMenuItem = new JMenuItem();
jMenuItem.setText("salut");
}
return jMenuItem;
}
/**
* This method initializes jMenuItem1
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem1() {
if (jMenuItem1 == null) {
jMenuItem1 = new JMenuItem();
jMenuItem1.setText("merci");
}
return jMenuItem1;
}
/**
* @param args
*/
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);
}
});
}
/**
* This is the default constructor
*/
public menu() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(605, 277);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJPanel(), null);
}
return jContentPane;
}
} // @jve:decl-index=0:visual-constraint="10,10" |
Partager