private JMenu getJMenu0() { if (jMenu0 == null) { jMenu0 = new JMenu(); jMenu0.setText("Menu"); jMenu0.setBorderPainted(true); jMenu0.setOpaque(false); jMenu0.setRolloverEnabled(false); jMenu0.add(getJMenuItem0()); } return jMenu0; }
/** * Constructs a JMenuBar that can be added to a JFrame * * @return a JMenuBar */ private JMenuBar menuBar() { JMenuBar mb = new JMenuBar(); JMenu fileMenu, editMenu, viewMenu, helpMenu, newEntry, viewDatabase; JMenuItem newChild, newEmployee, newAccount, openChild, viewFileChild, viewFileEmployee, saveChild, saveAs, printDocument, properties, viewDatabaseChild, viewDatabaseEmployee, viewFinances, viewCalendar, exit, cut, copy, paste, help, faq, report, about, checkupdate; // Initialize JMenu's fileMenu = new JMenu(lang_model.getValue(12)); editMenu = new JMenu(lang_model.getValue(23)); viewMenu = new JMenu(lang_model.getValue(27)); helpMenu = new JMenu(lang_model.getValue(33)); fileMenu.setRolloverEnabled(true); editMenu.setRolloverEnabled(true); helpMenu.setRolloverEnabled(true); // Initialize sub-JMenu's newEntry = new JMenu(lang_model.getValue(13)); newEntry.setIcon(images.loadImage("Images/menubar/application_icon.png")); openChild = new JMenu(lang_model.getValue(14)); openChild.setIcon(images.loadImage("Images/menubar/XML_icon_small.png")); viewDatabase = new JMenu(lang_model.getValue(29)); viewDatabase.setIcon(images.loadImage("Images/menubar/database_icon.png")); // Initialize JMenuItem's newChild = new JMenuItem(lang_model.getValue(20)); newEmployee = new JMenuItem(lang_model.getValue(21)); newAccount = new JMenuItem(lang_model.getValue(22)); saveChild = new JMenuItem(lang_model.getValue(15), images.loadImage("Images/menubar/save_icon.png")); saveAs = new JMenuItem(lang_model.getValue(16)); printDocument = new JMenuItem(lang_model.getValue(18), images.loadImage("Images/menubar/print_icon.png")); properties = new JMenuItem( lang_model.getValue(17), images.loadImage("Images/menubar/properties_icon.png")); viewCalendar = new JMenuItem( lang_model.getValue(28), images.loadImage("Images/menubar/calendar_icon.png")); viewDatabaseChild = new JMenuItem(lang_model.getValue(31)); viewDatabaseEmployee = new JMenuItem(lang_model.getValue(32)); viewFileChild = new JMenuItem(lang_model.getValue(20)); viewFileEmployee = new JMenuItem(lang_model.getValue(21)); saveChild.setEnabled(false); saveAs.setEnabled(false); printDocument.setEnabled(false); viewCalendar.setEnabled(false); viewFinances = new JMenuItem( lang_model.getValue(30), images.loadImage("Images/menubar/finances_icon_small.png")); exit = new JMenuItem(lang_model.getValue(19)); cut = new JMenuItem(lang_model.getValue(24), images.loadImage("Images/menubar/cut_icon.png")); copy = new JMenuItem(lang_model.getValue(25), images.loadImage("Images/menubar/copy_icon.png")); paste = new JMenuItem(lang_model.getValue(26), images.loadImage("Images/menubar/paste_icon.png")); viewFinances.setEnabled(false); cut.setEnabled(false); copy.setEnabled(false); paste.setEnabled(false); help = new JMenuItem(lang_model.getValue(33), images.loadImage("Images/menubar/help_icon.png")); faq = new JMenuItem(lang_model.getValue(34)); report = new JMenuItem(lang_model.getValue(35)); about = new JMenuItem( lang_model.getValue(36), images.loadImage("Images/menubar/exclamation_icon.png")); checkupdate = new JMenuItem(lang_model.getValue(105)); faq.setEnabled(false); checkupdate.setEnabled(false); // Add JMenuItem's to the JMenu's fileMenu.add(newEntry); newEntry.add(newChild); // Sub-Menu of fileMenu newEntry.add(newEmployee); // Sub-Menu of fileMenu newEntry.add(newAccount); // Sub-Menu of fileMenu fileMenu.add(openChild); openChild.add(viewFileChild); openChild.add(viewFileEmployee); // fileMenu.add(view); fileMenu.addSeparator(); fileMenu.add(saveChild); fileMenu.add(saveAs); fileMenu.addSeparator(); fileMenu.add(printDocument); fileMenu.addSeparator(); fileMenu.add(properties); fileMenu.addSeparator(); fileMenu.add(exit); editMenu.add(cut); editMenu.add(copy); editMenu.add(paste); viewMenu.add(viewCalendar); viewMenu.add(viewDatabase); viewDatabase.add(viewDatabaseChild); viewDatabase.add(viewDatabaseEmployee); viewMenu.add(viewFinances); helpMenu.add(help); helpMenu.add(faq); helpMenu.add(report); helpMenu.add(about); helpMenu.add(checkupdate); // Add JMenu's to the MenuBar mb.add(fileMenu); mb.add(editMenu); mb.add(viewMenu); mb.add(helpMenu); // Mnemonics fileMenu.setMnemonic('F'); newEntry.setMnemonic('N'); editMenu.setMnemonic('E'); viewMenu.setMnemonic('V'); helpMenu.setMnemonic('H'); // Accelerators newChild.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); newEmployee.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); saveChild.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); printDocument.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); viewFinances.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); viewCalendar.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); // Action Listening newChild.setActionCommand("newchild"); newChild.addActionListener(this); newEmployee.setActionCommand("newemployee"); newEmployee.addActionListener(this); newAccount.setActionCommand("newaccount"); newAccount.addActionListener(this); openChild.setActionCommand("openfile"); openChild.addActionListener(this); viewFileChild.setActionCommand("viewfilechild"); viewFileChild.addActionListener(this); viewFileEmployee.setActionCommand("viewfileemployee"); viewFileEmployee.addActionListener(this); viewDatabaseChild.setActionCommand("viewchilddatabase"); viewDatabaseChild.addActionListener(this); viewDatabaseEmployee.setActionCommand("viewemployeedatabase"); viewDatabaseEmployee.addActionListener(this); viewFinances.setActionCommand("viewfinances"); viewFinances.addActionListener(this); viewCalendar.setActionCommand("viewcalendar"); viewCalendar.addActionListener(this); printDocument.setActionCommand("printdocument"); printDocument.addActionListener(this); properties.setActionCommand("properties"); properties.addActionListener(this); exit.setActionCommand("exit"); exit.addActionListener(this); help.setActionCommand("help"); help.addActionListener(this); faq.setActionCommand("faq"); faq.addActionListener(this); report.setActionCommand("reportbug"); report.addActionListener(this); about.setActionCommand("about"); about.addActionListener(this); checkupdate.setActionCommand("checkupdate"); checkupdate.addActionListener(this); return mb; }