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
| package principal;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.JTable;
public class PopupMenuExample extends JPanel implements ActionListener{
private static final long serialVersionUID = 1L;
public JPopupMenu popupMenu;
private int IdKey;
public PopupMenuExample() {
popupMenu = new JPopupMenu();
// ActionListener menuListener = new ActionListener() {
// }
JMenu mnB = new JMenu("BAUTISMO\n");
mnB.setFont(new Font("Lucida Grande", Font.BOLD, 12));
popupMenu.add(mnB);
JMenuItem mntmRptB01 = new JMenuItem("Acta de Bautismo");
mntmRptB01.setIcon(new ImageIcon("/Users/aCedano/Pictures/Imagenes/16x16-free-application-icons/png/16x16/About.png"));
mntmRptB01.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mntmRptB01.addActionListener(this);
mnB.add(mntmRptB01);
mnB.addSeparator();
JMenuItem mntmRptB02 = new JMenuItem("Reporte Bautizados en \u00E9sta fecha");
mntmRptB02.setIcon(new ImageIcon("/Users/aCedano/Pictures/Imagenes/16x16-free-application-icons/png/16x16/Downloads folder.png"));
mntmRptB02.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mntmRptB02.addActionListener(this);
mnB.add(mntmRptB02);
mnB.addSeparator();
JSeparator separator = new JSeparator();
popupMenu.add(separator);
JMenu mnC = new JMenu("CONFIRMACI\u00D3N");
mnC.setFont(new Font("Lucida Grande", Font.BOLD, 12));
popupMenu.add(mnC);
JMenuItem mntmRptC01 = new JMenuItem("Acta de Confirmaci\u00F3n");
mntmRptC01.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mnC.add(mntmRptC01);
JMenuItem mntmC21 = new JMenuItem("Reporte al Obispado");
mntmC21.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mnC.add(mntmC21);
JSeparator separator_1 = new JSeparator();
popupMenu.add(separator_1);
JMenu mnM = new JMenu("MATRIMONIO");
mnM.setFont(new Font("Lucida Grande", Font.BOLD, 12));
popupMenu.add(mnM);
JMenuItem mntmM01 = new JMenuItem("Acta de Matrimonio");
mntmM01.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mnM.add(mntmM01);
JMenuItem mntmRptM21 = new JMenuItem("Notificaci\u00F3n a Parroquia de Bautismo");
mntmRptM21.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mnM.add(mntmRptM21);
JSeparator separator_2 = new JSeparator();
popupMenu.add(separator_2);
JMenu mnE = new JMenu("EUCARIST\u00CDA");
mnE.setFont(new Font("Lucida Grande", Font.BOLD, 12));
popupMenu.add(mnE);
JMenuItem mntmRptE01 = new JMenuItem("Acta de 1ra Comuni\u00F3n");
mntmRptE01.setFont(new Font("Lucida Grande", Font.ITALIC, 12));
mnE.add(mntmRptE01);
}
public void actionPerformed(ActionEvent event) {
JMenuItem source = (JMenuItem) (event.getSource());
String s = "Menu Item source: " + source.getText();
System.out.println(IdKey + " " +s);
}
public void show(JTable jtbProducto, int xposition, int yposition, int IdKey) {
// TODO Auto-generated method stub
this.IdKey = IdKey;
popupMenu.show(jtbProducto, xposition, yposition);
}
} |
Partager