public void updateConnectionStatus(boolean connected) { if (connected == true) { headerPanel.setLogoutText(); loginMenuItem.setText("Logout"); } else { headerPanel.setLoginText(); loginMenuItem.setText("Login..."); } mainCommandPanel.updateConnectionStatus(connected); propertiePanel.updateConnectionStatus(connected); cmdConsole.updateConnectionStatus(connected); Iterator iterator = plugins.iterator(); PluginPanel updatePluginPanel = null; while (iterator.hasNext()) { updatePluginPanel = (PluginPanel) iterator.next(); updatePluginPanel.updateConnectionStatus(connected); } if (connected == true) { int selected = tabbedPane.getSelectedIndex(); if (selected >= 2) { ((PluginPanel) pluginPanelMap.get("" + selected)).activated(); } } }
protected JMenu getModelingMenu() { JMenu modelingMenu = new JMenu(STRINGS.MODELING_MENU); JMenuItem ganntMenuItem = new JMenuItem(); ganntMenuItem.setText(STRINGS.GANTT); modelingMenu.add(ganntMenuItem); JMenuItem parameterMenuItem = new JMenuItem(); parameterMenuItem.setText(STRINGS.CPU_PARAMETERS); modelingMenu.add(parameterMenuItem); return modelingMenu; }
/** * This function is called when an observable notify the AppFrame * * @param o an observable * @param arg the arg of the observable */ @Override public void update(Observable o, Object arg) { this.toolsMenuItems.clear(); this.tools.removeAll(); /* TODO: En 2 observers 1 pour ajouter 1 pour supprimer */ for (File f : this.pluginFinder.getFoundFiles()) { final Plugin plugin = this.createPlugin(f); JMenuItem toolsMenuItem = new JMenuItem(); toolsMenuItem.setText(plugin.getDescription()); toolsMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textArea.setText(plugin.doAction(textArea.getText())); } }); this.toolsMenuItems.add(toolsMenuItem); this.tools.add(toolsMenuItem); } }
void windowMenu_menuSelected(MenuEvent e) { // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes // the Window // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon // Aquino] if (windowMenu.getItemCount() > 0 && windowMenu.getItem(0) != null && windowMenu .getItem(0) .getText() .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) { JMenuItem newWindowMenuItem = windowMenu.getItem(0); windowMenu.removeAll(); windowMenu.add(newWindowMenuItem); windowMenu.addSeparator(); } else { // ezLink doesn't have a Clone Window menu [Jon Aquino] windowMenu.removeAll(); } // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames(); final JInternalFrame[] frames = desktopPane.getAllFrames(); for (int i = 0; i < frames.length; i++) { JMenuItem menuItem = new JMenuItem(); // Increase truncation threshold from 20 to 40, for eziLink [Jon // Aquino] menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40)); associate(menuItem, frames[i]); windowMenu.add(menuItem); } if (windowMenu.getItemCount() == 0) { // For ezLink [Jon Aquino] windowMenu.add(new JMenuItem("(No Windows)")); } }
/** * Adds a Display menu to the menu bar. Overrides OSPFrame method. * * @return the display menu */ protected JMenu loadDisplayMenu() { JMenuBar menuBar = getJMenuBar(); if (menuBar == null) { return null; } JMenu menu = super.loadDisplayMenu(); translateItem = new JMenuItem(); translateItem.setText(ControlsRes.getString("OSPControl.Translate")); // $NON-NLS-1$ // changed by D Brown 2007-10-17 if (OSPRuntime.translator != null) { translateItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { OSPRuntime.translator.showProperties(model.getClass()); if (OSPRuntime.translator instanceof Hidable) ((Hidable) OSPRuntime.translator).setKeepHidden(false); OSPRuntime.translator.setVisible(true); } }); translateItem.setEnabled(OSPRuntime.isAuthorMode()); languageMenu.add(translateItem, 0); } // changed by D Brown 2006-09-10 if (languageMenu.getItemCount() > 1) languageMenu.insertSeparator(1); return menu; }
private JMenuItem getJMenuItem3() { if (jMenuItem3 == null) { jMenuItem3 = new JMenuItem(); jMenuItem3.setText("Solution"); jMenuItem3.setMnemonic(java.awt.event.KeyEvent.VK_S); jMenuItem3.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_S, java.awt.Event.CTRL_MASK, false)); jMenuItem3.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { solution = true; current = new ArrayList<String>(correct); shuffle(); getStatusLabel().setText("Correct solution."); // Change the buttons colors to green Iterator itr = buttons.iterator(); while (itr.hasNext()) { ((JButton) itr.next()).setBackground(java.awt.Color.green); } } }); } return jMenuItem3; }
public JMenuItem getBinarise() { if (binarise == null) { binarise = new JMenuItem(); binarise.setText("Binarise"); binarise.setAction(getBinariseAction()); } return binarise; }
public JMenuItem getInvertMenuItem() { if (invertMenuItem == null) { invertMenuItem = new JMenuItem(); invertMenuItem.setText("Invert"); invertMenuItem.setAction(getInvertAction()); } return invertMenuItem; }
public JMenuItem getConnectedMenuItem() { if (connectedMenuItem == null) { connectedMenuItem = new JMenuItem(); connectedMenuItem.setText("Find connected"); connectedMenuItem.setAction(getFindConnectedAction()); } return connectedMenuItem; }
private void configureItem(OptionInfo info, JMenuItem eachItem) { eachItem.setText(info.myPlainText); if (info.myMnemonic >= 0) { eachItem.setMnemonic(info.myMnemonic); eachItem.setDisplayedMnemonicIndex(info.myMnemonicIndex); } myOptionInfos.add(info); }
public JMenuItem getScaleMenuItem() { if (scaleMenuItem == null) { scaleMenuItem = new JMenuItem(); scaleMenuItem.setText("Scale 2x"); scaleMenuItem.setAction(getScaleAction()); } return scaleMenuItem; }
public JMenuItem getOtsubinary() { if (otsubinary == null) { otsubinary = new JMenuItem(); otsubinary.setText("Otsu binarisation"); otsubinary.setAction(getOstuBinaryAction()); } return otsubinary; }
private JMenuItem getGrayScale() { if (grayScale == null) { grayScale = new JMenuItem(); grayScale.setText("Gray level"); grayScale.setAction(getGrayScaleAction()); } return grayScale; }
public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); if (e.getPropertyName().equals(Action.NAME)) { String text = (String) e.getNewValue(); menuItem.setText(text); } else if (propertyName.equals("enabled")) { Boolean enabledState = (Boolean) e.getNewValue(); menuItem.setEnabled(enabledState.booleanValue()); } }
public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); if (e.getPropertyName().equals(Action.NAME)) { String text = (String) e.getNewValue(); menuItem.setText(text); } else if (propertyName.equals("enabled")) { // System.out.println("Debug:TextViewer: ActionChangedListener enabled"); Boolean enabledState = (Boolean) e.getNewValue(); menuItem.setEnabled(enabledState.booleanValue()); } }
/** * This method initializes cloneGroupPopupMenuItem * * @return javax.swing.JMenuItem */ public JMenuItem getCloneGroupPopupMenuItem() { if (cloneGroupPopupMenuItem == null) { cloneGroupPopupMenuItem = new JMenuItem(); cloneGroupPopupMenuItem.addActionListener(actionListener); cloneGroupPopupMenuItem.setActionCommand(ActionConstants.CLONE_GROUP_ACTION); cloneGroupPopupMenuItem.setIcon(ResourceUtil.cloneGroupIcon); cloneGroupPopupMenuItem.setText(ResourceUtil.getString("menu.clone")); cloneGroupPopupMenuItem.setEnabled(false); } return cloneGroupPopupMenuItem; }
/* * Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent). */ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { createOtrContactMenus(currentContact); JMenu menu = getMenu(); menu.addSeparator(); whatsThis = new JMenuItem(); whatsThis.setIcon(OtrActivator.resourceService.getImage("plugin.otr.HELP_ICON_15x15")); whatsThis.setText(OtrActivator.resourceService.getI18NString("plugin.otr.menu.WHATS_THIS")); whatsThis.addActionListener(this); menu.add(whatsThis); }
/** * This method initializes addGroupPopupMenuItem * * @return javax.swing.JMenuItem */ public JMenuItem getAddGroupPopupMenuItem() { if (addGroupPopupMenuItem == null) { addGroupPopupMenuItem = new JMenuItem(); addGroupPopupMenuItem.addActionListener(actionListener); addGroupPopupMenuItem.setActionCommand(ActionConstants.ADD_GROUP_ACTION); addGroupPopupMenuItem.setIcon(ResourceUtil.addGroupIcon); addGroupPopupMenuItem.setText(ResourceUtil.getString("button.add")); addGroupPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.addgroup.tooltip")); } return addGroupPopupMenuItem; }
/** * This method initializes deleteGroupPopupMenuItem. * * @return javax.swing.JMenuItem */ public JMenuItem getDeleteGroupPopupMenuItem() { if (deleteGroupPopupMenuItem == null) { deleteGroupPopupMenuItem = new JMenuItem(); deleteGroupPopupMenuItem.addActionListener(actionListener); deleteGroupPopupMenuItem.setActionCommand(ActionConstants.DELETE_GROUP_ACTION); deleteGroupPopupMenuItem.setIcon(ResourceUtil.deleteGroupIcon); deleteGroupPopupMenuItem.setText(ResourceUtil.getString("button.delete")); deleteGroupPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.deletegroup.tooltip")); deleteGroupPopupMenuItem.setEnabled(false); } return deleteGroupPopupMenuItem; }
/** * This method initializes renameGroupPopupMenuItem. * * @return javax.swing.JMenuItem */ public JMenuItem getRenameGroupPopupMenuItem() { if (renameGroupPopupMenuItem == null) { renameGroupPopupMenuItem = new JMenuItem(); renameGroupPopupMenuItem.addActionListener(actionListener); renameGroupPopupMenuItem.setActionCommand(ActionConstants.RENAME_GROUP_ACTION); renameGroupPopupMenuItem.setIcon(ResourceUtil.renameGroupIcon); renameGroupPopupMenuItem.setText(ResourceUtil.getString("button.rename")); renameGroupPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.renamegroup.tooltip")); renameGroupPopupMenuItem.setEnabled(false); } return renameGroupPopupMenuItem; }
/** * This method initializes addRemoveMembersPopupMenuItem. * * @return javax.swing.JMenuItem */ public JMenuItem getAddRemoveMembersPopupMenuItem() { if (addRemoveMembersPopupMenuItem == null) { addRemoveMembersPopupMenuItem = new JMenuItem(); addRemoveMembersPopupMenuItem.addActionListener(actionListener); addRemoveMembersPopupMenuItem.setActionCommand(ActionConstants.ADD_REMOVE_MEMBERS_ACTION); addRemoveMembersPopupMenuItem.setIcon(ResourceUtil.addRemoveMembersIcon); addRemoveMembersPopupMenuItem.setText( ResourceUtil.getString("mainframe.button.addremovemembers")); addRemoveMembersPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.addremovemembers.tooltip")); addRemoveMembersPopupMenuItem.setEnabled(false); } return addRemoveMembersPopupMenuItem; }
public static JMenuItem createMenuItem(Object[] data) { JMenuItem m = null; MType type = (MType) data[1]; if (type == mi) m = new JMenuItem(); else if (type == cb) m = new JCheckBoxMenuItem(); else if (type == rb) { m = new JRadioButtonMenuItem(); bgroup.add(m); } m.setText((String) data[0]); m.setMnemonic(((Character) data[2]).charValue()); m.addActionListener((ActionListener) data[3]); m.setEnabled(((Boolean) data[4]).booleanValue()); if (data.length == 6) m.setIcon((Icon) data[5]); return m; }
/** * This method initializes jMenuItem * * @return JMenuItem */ private JMenuItem getJMenuItem() { if (jMenuItem == null) { jMenuItem = new JMenuItem(); jMenuItem.setText("New Game"); jMenuItem.setMnemonic(java.awt.event.KeyEvent.VK_N); jMenuItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_N, java.awt.Event.CTRL_MASK, false)); jMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { shuffle(); } }); } return jMenuItem; }
/** * This method initializes jMenuItem1 * * @return JMenuItem */ private JMenuItem getJMenuItem1() { if (jMenuItem1 == null) { jMenuItem1 = new JMenuItem(); jMenuItem1.setText("Quit"); jMenuItem1.setMnemonic(java.awt.event.KeyEvent.VK_X); jMenuItem1.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_X, java.awt.Event.CTRL_MASK, false)); jMenuItem1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.exit(0); } }); } return jMenuItem1; }
private void configureRichTextAction( ISQLPanelAPI sqlPanelAPI, SquirrelRSyntaxTextArea rsEdit, String rtaKey, KeyStroke acceleratorKeyStroke, String acceleratorDescription, String shortDescription) { Action action = SquirreLRSyntaxTextAreaUI.getActionForName(rsEdit, rtaKey); action.putValue(Resources.ACCELERATOR_STRING, acceleratorDescription); action.putValue(Action.SHORT_DESCRIPTION, shortDescription); action.putValue(Action.MNEMONIC_KEY, 0); action.putValue(Action.ACCELERATOR_KEY, acceleratorKeyStroke); JMenuItem mnu = sqlPanelAPI.addToSQLEntryAreaMenu(action); mnu.setText((String) action.getValue(Action.SHORT_DESCRIPTION)); _resources.configureMenuItem(action, mnu); }
private JMenuItem getJMenuItem2() { if (jMenuItem2 == null) { jMenuItem2 = new JMenuItem(); jMenuItem2.setText("Image Path"); jMenuItem2.setMnemonic(java.awt.event.KeyEvent.VK_O); jMenuItem2.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_O, java.awt.Event.CTRL_MASK, false)); jMenuItem2.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { // System.exit(0); jFileChooser = new JFileChooser(); jFileChooser.setDialogTitle("Select image directory."); jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jFileChooser.setAcceptAllFileFilterUsed(false); if (jFileChooser.showOpenDialog(jPanel) == JFileChooser.APPROVE_OPTION) { path = jFileChooser.getSelectedFile() + "/"; solution = true; current = new ArrayList<String>(correct); for (int i = 1; i <= 16; i++) { // Add the icons in correct order icons[i - 1] = new ImageIcon(path + i + ".jpg"); } shuffle(); getStatusLabel().setText("New game started."); // Change the buttons colors to green Iterator itr = buttons.iterator(); while (itr.hasNext()) { ((JButton) itr.next()).setBackground(java.awt.Color.green); } } } }); } return jMenuItem2; }
public static void addFastKeys(JMenuBar menuBar) { for (Component menuComponent : menuBar.getComponents()) { // iterate over menus JMenu menu = (JMenu) menuComponent; menu.setMnemonic(menu.getText().charAt(menu.getText().indexOf('&') + 1)); menu.setText(menu.getText().replace("&", "")); for (Component menuItemComponent : menu.getMenuComponents()) if (menuItemComponent instanceof JMenuItem) { // skip separators JMenuItem menuItem = (JMenuItem) menuItemComponent; menuItem.setMnemonic(menuItem.getText().charAt(menuItem.getText().indexOf('&') + 1)); menuItem.setText(menuItem.getText().replace("&", "")); } /* for (int count = 0; count < menu.getMenuComponentCount(); count++) { //iterate over menu items Component menuItemComponent = menu.getMenuComponent(count); if (menuItemComponent instanceof JMenuItem) { //skip separators JMenuItem menuItem = (JMenuItem)menuItemComponent; menuItem.setMnemonic(menuItem.getText().charAt( menuItem.getText().indexOf('&') + 1)); menuItem.setText(menuItem.getText().replace("&", "")); } } */ } }
public SearchPatient(final String type, final int docID) { try { // "Load" the JDBC driver Class.forName("java.sql.Driver"); // Establish the connection to the database String url = "jdbc:mysql://localhost:3306/cse"; conn = DriverManager.getConnection(url, "root", "admin"); } catch (Exception e) { System.err.println("Got an exception!"); System.err.println(e.getMessage()); } // Menu // MENU ACTIONS // Action to view new patient registered class NewPatientAction extends AbstractAction { private static final long serialVersionUID = 1L; public NewPatientAction() { putValue(SHORT_DESCRIPTION, "View list of new patients"); } public void actionPerformed(ActionEvent e) { ViewRegisteredPatients vp = new ViewRegisteredPatients("new"); vp.setVisible(true); ViewRegisteredPatients.hasNew = false; } } Action newPatientAction = new NewPatientAction(); // Action to view all patient registered class AllPatientAction extends AbstractAction { private static final long serialVersionUID = 1L; public AllPatientAction() { putValue(SHORT_DESCRIPTION, "View list of all patients"); } public void actionPerformed(ActionEvent e) { ViewRegisteredPatients vp = new ViewRegisteredPatients("all"); vp.setVisible(true); } } Action allPatientAction = new AllPatientAction(); // Action to open Statistical Report class StatsReportAction implements MenuListener { public void menuSelected(MenuEvent e) { StatsReport report = new StatsReport(); setAlwaysOnTop(false); report.setVisible(true); report.setAlwaysOnTop(true); } public void menuDeselected(MenuEvent e) {} public void menuCanceled(MenuEvent e) {} } // Action to open Statistical Report class ProfileAction implements MenuListener { public void menuSelected(MenuEvent e) { Profile profilePage = new Profile("staff", docID, type); profilePage.setVisible(true); dispose(); } public void menuDeselected(MenuEvent e) {} public void menuCanceled(MenuEvent e) {} } // MENU COMPONENTS menu = new JMenuBar(); menuOp1 = new JMenu(); menuOp2 = new JMenu(); menuOp3 = new JMenu(); menuOp4 = new JMenu(); menuOp5 = new JMenu(); menuOp1.setText("Profile"); menuOp1.addMenuListener(new ProfileAction()); optionsFrame = new JFrame("Options"); optionsContainer = new JPanel(); optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.Y_AXIS)); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); if (type.equals("Doctor")) // if a doctor is logging in { menuOp2.setText("Patients"); menuOp3.setText("Appointments Request"); menuOp4.setText("View Medical Alerts"); menuItem1 = new JMenuItem("Search Patient"); menuOp2.add(menuItem1); menu.add(menuOp1); menu.add(menuOp2); menu.add(menuOp3); menu.add(menuOp4); // optionsFrame optionUpdateHCC = new JLabel("Update Healthcare Condition"); optionUpdateHCC.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionUpdateHCC.addMouseListener(new MouseUpdateHCCListener()); optionPrescription = new JLabel("e-Prescription"); optionPrescription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); // optionPrescription.addMouseListener(new MousePrescriptionListener()); optionLabRecord = new JLabel("View Lab Records"); optionLabRecord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionLabRecord.addMouseListener(new MouseLabRecordListener()); optionUpdateHCR = new JLabel("Update Healthcare Records"); optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener()); // add option to container optionsContainer.add(optionUpdateHCC); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionPrescription); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionLabRecord); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionLabRecord); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionUpdateHCR); } else if (type.equals("HSP")) // if the HSP is logging in { menuOp2.setText("Patients"); menuOp3.setText("Appointment Request"); menuOp4.setText("View Medical Alerts"); menuOp5.setText("Generate Statistical Report"); menuOp5.addMenuListener(new StatsReportAction()); menuItem1 = new JMenuItem("Search Patient"); menuOp6 = new JMenu("List of Registered Patient"); menuOp6.setMnemonic(KeyEvent.VK_S); menuItem2 = new JMenuItem(newPatientAction); menuItem2.setText("List of New Registered Patient"); menuItem3 = new JMenuItem(allPatientAction); menuItem3.setText("List of All Registered Patient"); menuOp2.add(menuItem1); menuOp2.add(menuOp6); menuOp6.add(menuItem2); menuOp6.add(menuItem3); menu.add(menuOp1); menu.add(menuOp2); menu.add(menuOp3); menu.add(menuOp4); menu.add(menuOp5); // optionsFrame optionUpdateHCC = new JLabel("Update Healthcare Condition"); optionUpdateHCC.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionUpdateHCC.addMouseListener(new MouseUpdateHCCListener()); optionLabRecord = new JLabel("View Lab Records"); optionLabRecord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionLabRecord.addMouseListener(new MouseLabRecordListener()); optionHCR = new JLabel("Upload Healthcare Records"); optionHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionHCR.addMouseListener(new MouseUploadHCRListener()); optionUpdateHCR = new JLabel("Update Healthcare Records"); optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener()); // add option to container optionsContainer.add(optionUpdateHCC); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionLabRecord); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionLabRecord); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionHCR); optionsContainer.add(Box.createRigidArea(new Dimension(20, 5))); optionsContainer.add(optionUpdateHCR); } else if (type.equals("Pharmacist")) // if the Pharmacist is logging in { menuOp2.setText("Patients"); menuItem1 = new JMenuItem("Search Patients"); menuOp2.add(menuItem1); menu.add(menuOp1); menu.add(menuOp2); // optionsFrame optionViewPrescription = new JLabel("View e-Prescription"); optionViewPrescription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionViewPrescription.addMouseListener(new MouseViewPrescriptionListener()); // add option to container optionsContainer.add(optionViewPrescription); } else if (type.equals("Nurse")) // if the nurse is logging in { menuOp2.setText("Patients"); menuItem1 = new JMenuItem("Search Patients"); menuOp2.add(menuItem1); menu.add(menuOp1); menu.add(menuOp2); // optionsFrame optionUpdateHCR = new JLabel("Update Healthcare Records"); optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener()); // add option to container optionsContainer.add(optionUpdateHCR); } // Labels firstNameLabel = new JLabel(" First name:"); // first name label lastNameLabel = new JLabel("Last name:"); // last name label patientListLabel = new JLabel("Patient List:"); // patient list label // Text Fields firstNameField = new JTextField(10); // first name text field lastNameField = new JTextField(10); // last name text field // Buttons searchButton = new JButton("Search"); // search button searchButton.addActionListener(new SearchButtonListener()); // add listener selectButton = new JButton("Select"); selectButton.addActionListener(new SelectButtonListener()); // add listener cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new CancelButtonListener()); // add listener // JPanels firstNamePanel = new JPanel(); // First name panel firstNamePanel.add(firstNameLabel); firstNamePanel.add(firstNameField); lastNamePanel = new JPanel(); // Last name panel lastNamePanel.add(lastNameLabel); lastNamePanel.add(lastNameField); patientInfoPanel = new JPanel(); patientInfoPanel.setLayout(new BoxLayout(patientInfoPanel, BoxLayout.X_AXIS)); patientInfoPanel.add(firstNamePanel); patientInfoPanel.add(lastNamePanel); patientInfoPanel.add(searchButton); buttonPanel = new JPanel(); // button panel buttonPanel.add(selectButton); buttonPanel.add(cancelButton); // Patient List patientVector = new Vector(); // Vector of Patient objects patientList = new JList(patientVector); // creates a JList that show the content of the recordVector scrollPatientList = new JScrollPane(patientList); // add scroll option to the list patientList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION); // Allow the selection of only one item at a time String[] patients = new String[1000000]; // Populates the patient list with the patients from the database if (type.equals("Doctor")) { int i = 0; try { // checks if the patient is a patient of the doctor logged statement = conn.createStatement(); rs = statement.executeQuery( "SELECT * FROM appointments WHERE `docID`='" + docID + "' ORDER BY `patientID`"); while (rs.next()) { int patientID = rs.getInt("patientID"); patients[i] = String.valueOf(patientID); i++; } String[] patientSet = (String[]) new HashSet(Arrays.asList(patients)).toArray(new String[0]); // gets information from the specific set of patients for (int j = 0; j < patientSet.length; j++) { statement = conn.createStatement(); rs = statement.executeQuery( "SELECT * FROM patient WHERE `idpatient`='" + patientSet[j] + "';"); while (rs.next()) { Patient obj = new Patient(); obj.setFirstName(rs.getString("fname")); obj.setLastName(rs.getString("lname")); obj.setDOB(rs.getString("dob")); obj.setPatientId(Integer.parseInt(patientSet[j])); patientVector.add(obj); } } } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); System.err.println(e); } } else { try { statement = conn.createStatement(); rs = statement.executeQuery("SELECT * FROM patient ORDER BY fname"); while (rs.next()) { Patient obj = new Patient(); obj.setFirstName(rs.getString("fname")); obj.setLastName(rs.getString("lname")); obj.setDOB(rs.getString("dob")); obj.setPatientId(rs.getInt("idpatient")); patientVector.add(obj); } } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); } } searchVector = new Vector(); // set options frame optionsFrame.add(optionsContainer); optionsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // close the window on close optionsFrame.setSize(300, 150); // set size of window optionsFrame.setLocation(600, 280); optionsFrame.setVisible(false); searchPanel = new JPanel(); searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.Y_AXIS)); searchPanel.add(patientInfoPanel); searchPanel.add(patientListLabel); searchPanel.add(scrollPatientList); searchPanel.add(buttonPanel); Border padding = BorderFactory.createEmptyBorder(20, 20, 10, 10); searchPanel.setBorder(padding); setJMenuBar(menu); add(searchPanel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(1200, 580); }
private void initGUI() { try { getContentPane().add(getImagePanel(), BorderLayout.CENTER); this.setSize(600, 500); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAction(getOpenFile()); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenuBar1.add(getMenuFilter()); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } }
public JMenuBar getMenuBar() { jMenuAbout.setText("About"); jMenuAbout.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.jMenuHelpAbout_actionPerformed(e); } }); jMenuView.setText("View"); jMenuFileExit.setText("Exit"); jMenuFileExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.jMenuFileExit_actionPerformed(e); } }); jMenuEdit.setText("Edit"); menuExchangeGeom.setText("Exchange Geometries"); menuExchangeGeom.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuExchangeGeom_actionPerformed(e); } }); menuViewText.setText("Test Case Text..."); menuViewText.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuViewText_actionPerformed(e); } }); menuViewGeometry.setText("Geometry Inspector..."); menuViewGeometry.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.actionInspectGeometry(); } }); menuLoadXmlTestFile.setText("Open XML File(s)..."); menuLoadXmlTestFile.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuLoadXmlTestFile_actionPerformed(e); } }); saveAsXmlMenuItem.setText("Save As XML..."); saveAsXmlMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuSaveAsXml_actionPerformed(e); } }); saveAsHtmlMenuItem.setText("Save As HTML..."); saveAsHtmlMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuSaveAsHtml_actionPerformed(e); } }); saveAsPNGMenuItem.setText("Save As PNG..."); saveAsPNGMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuSaveAsPNG_actionPerformed(e); } }); saveToClipboardMenuItem.setText("Save Screen To Clipboard"); saveToClipboardMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuSaveScreenToClipboard_actionPerformed(e); } }); deleteAllTestCasesMenuItem.setText("Delete All Test Cases"); deleteAllTestCasesMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.deleteAllTestCasesMenuItem_actionPerformed(e); } }); showVerticesMenuItem.setText("Vertices"); showVerticesMenuItem.setSelected(true); showVerticesMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.setShowingVertices(showVerticesMenuItem.isSelected()); } }); final JCheckBoxMenuItem showLabelMenuItem = menuItem("Labels", true); showLabelMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.setShowingLabel(showLabelMenuItem.isSelected()); } }); showGridMenuItem.setText("Grid"); showGridMenuItem.setSelected(true); showGridMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.setShowingGrid(showGridMenuItem.isSelected()); } }); showStructureMenuItem.setText("Geometry Structure"); showStructureMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.setShowingStructure(showStructureMenuItem.isSelected()); } }); showOrientationsMenuItem.setText("Orientations"); showOrientationsMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.setShowingOrientations(showOrientationsMenuItem.isSelected()); } }); showVertexIndicesMenuItem.setText("Vertex Indices"); showVertexIndicesMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.setShowingVertices(showVerticesMenuItem.isSelected()); } }); menuLoadXmlTestFolder.setText("Open XML Folder(s)..."); menuLoadXmlTestFolder.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuLoadXmlTestFolder_actionPerformed(e); } }); precisionModelMenuItem.setText("Precision Model..."); precisionModelMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.precisionModelMenuItem_actionPerformed(e); } }); removeDuplicatePoints.setText("Remove Duplicate Points"); removeDuplicatePoints.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuRemoveDuplicatePoints_actionPerformed(e); } }); changeToLines.setText("Change to Lines"); changeToLines.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tbFrame.menuChangeToLines_actionPerformed(e); } }); generateExpectedValuesMenuItem.setText("Generate Expected Values"); generateExpectedValuesMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { // generateExpectedValuesMenuItem_actionPerformed(e); } }); jMenuFile.setText("File"); jMenuHelp.setText("Help"); // jMenuOptions.setText("Options"); // jMenuTools.setText("Tools"); jMenuFile.add(menuLoadXmlTestFile); jMenuFile.add(menuLoadXmlTestFolder); jMenuFile.add(saveAsPNGMenuItem); jMenuFile.add(saveToClipboardMenuItem); jMenuFile.add(saveAsXmlMenuItem); jMenuFile.add(saveAsHtmlMenuItem); jMenuFile.add(generateExpectedValuesMenuItem); jMenuFile.addSeparator(); jMenuFile.add(jMenuFileExit); jMenuHelp.add(jMenuAbout); jMenuView.add(showVerticesMenuItem); // jMenuOptions.add(showVertexIndicesMenuItem); jMenuView.add(showStructureMenuItem); jMenuView.add(showOrientationsMenuItem); jMenuView.add(showLabelMenuItem); jMenuView.addSeparator(); jMenuView.add(showGridMenuItem); jMenuView.addSeparator(); jMenuView.add(menuViewText); jMenuView.add(menuViewGeometry); jMenuEdit.add(deleteAllTestCasesMenuItem); jMenuEdit.add(menuExchangeGeom); jMenuEdit.addSeparator(); jMenuEdit.add(precisionModelMenuItem); jMenuEdit.addSeparator(); jMenuEdit.add(removeDuplicatePoints); jMenuEdit.add(changeToLines); jMenuBar1.add(jMenuFile); jMenuBar1.add(jMenuView); jMenuBar1.add(jMenuEdit); // jMenuBar1.add(jMenuOptions); // jMenuBar1.add(jMenuTools); jMenuBar1.add(jMenuHelp); return jMenuBar1; }