📄 mdi.java
字号:
private JInternalFrame showJInternalFrame(JInternalFrame jif, JPanel panel) throws PropertyVetoException { return showJInternalFrame(jif, panel, panel.getToolTipText()); } private JInternalFrame showJInternalFrame(JInternalFrame jif, JPanel panel, String title) throws PropertyVetoException { if (jif == null) { jif = new JInternalFrame(title); jif.setResizable(true); jif.setIconifiable(true); jif.setMaximizable(true); jif.setClosable(true); jif.setContentPane(panel); jif.pack(); desktopPane.add(jif); jif.setLocation((desktopPane.getWidth() - jif.getWidth()) / 2, (desktopPane.getHeight() - jif.getHeight()) / 2); } if (jif.isClosed()) { desktopPane.add(jif); } jif.setVisible(true); jif.setSelected(true); return jif; } private JInternalFrame showJInternalFrame(JInternalFrame jif, Class jPanelClass) { JInternalFrame newJIF = null; JPanel c = null; try { //not good. needs instaniation everytime if (jif == null) { c = (JPanel) jPanelClass.newInstance(); } else { c = (JPanel) jif.getContentPane(); } newJIF = showJInternalFrame(jif, c); } catch (PropertyVetoException ex) { Logger.getLogger(MDI.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(MDI.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(MDI.class.getName()).log(Level.SEVERE, null, ex); } return newJIF; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem aboutMenuItem; private javax.swing.JMenuItem appointmentMenuItem; private javax.swing.JLabel backgroundLabel; private javax.swing.JDesktopPane desktopPane; private javax.swing.JMenu emergencyInfoMenu; private javax.swing.JMenuItem exitMenuItem; private javax.swing.JMenuItem expensesMenuItem; private javax.swing.JMenu fileMenu; private javax.swing.JMenuItem generalHealthNotesMenuItem; private javax.swing.JMenuItem generalPixMenuItem; private javax.swing.JMenu helpMenu; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator2; private javax.swing.JSeparator jSeparator3; private javax.swing.JSeparator jSeparator4; private javax.swing.JSeparator jSeparator5; private javax.swing.JSeparator jSeparator6; private javax.swing.JCheckBoxMenuItem loginCheckBoxMenuItem; private javax.swing.JCheckBoxMenuItem logoutCheckBoxMenuItem; private javax.swing.JMenuItem medicalPixMenuItem; private javax.swing.JMenuItem medicationsMenuItem; private javax.swing.JMenuBar menuBar; private javax.swing.JMenuItem myAccountMenuItem; private javax.swing.JMenu ownerMenu; private javax.swing.JMenuItem petsMenuItem; private javax.swing.JLabel petvetLogoLabel; private javax.swing.JMenuItem preferencesMenuItem; private javax.swing.JMenuItem selectPetMenuItem; private javax.swing.JMenu serviceMenu; private javax.swing.JMenuItem serviceProvidersMenuItem; private javax.swing.JLabel spLogoLabel; private javax.swing.JPanel statusBarPanel; private javax.swing.JLabel statusLabel; private javax.swing.JMenuItem vaccinationsMenuItem; private javax.swing.JMenuItem vetVisitsMenuItem; // End of variables declaration//GEN-END:variables LoginView loginView; @Action public void login() { loginView = null; if (loginView == null) { loginView = new LoginView(this, true); loginView.pack(); loginView.setLocationRelativeTo(this); } loginView.setVisible(true); } @Action public void logout() { Session.getInstance().logout(); //this.setVisible(false); //new LoginView(true).setVisible(true); } public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(Session.PROPERTYNAME_BACKGROUND_IMAGE_FILE)) { reConfigBackground(); return; } if (evt.getPropertyName().equals(Session.PROPERTYNAME_LOGIN_STATE)) { boolean loginState = (Boolean) evt.getNewValue(); setStatusBar(evt); //setVisible(loginState); loginCheckBoxMenuItem.setSelected(loginState); logoutCheckBoxMenuItem.setSelected(!loginState); this.ownerMenu.setEnabled(loginState && session.getUserType() == Petsowner.class); this.serviceMenu.setEnabled(loginState); closeInternalFrames();// if (!loginState) {// login();// } return; } if (evt.getPropertyName().equals(Session.PROPERTYNAME_PET)) { //close and dispose all interframes //set statusbar boolean petSelected = (evt.getNewValue() != null); vetVisitsMenuItem.setEnabled(petSelected); medicationsMenuItem.setEnabled(petSelected); vaccinationsMenuItem.setEnabled(petSelected); generalHealthNotesMenuItem.setEnabled(petSelected); setStatusBar(evt); closeInternalFrames(); return; } if (evt.getPropertyName().equals(Session.PROPERTYNAME_USER_TYPE)) { //set status bar //set menu setStatusBar(evt); boolean owner = (Class) evt.getNewValue() == Petsowner.class; //this.expensesMenuItem.setEnabled(owner); //this.selectMenuItem.setEnabled(owner); this.ownerMenu.setEnabled(owner); closeInternalFrames(); return; } if (evt.getPropertyName().equals(Session.PROPERTYNAME_USER)) { setStatusBar(evt); return; } } JInternalFrame expenseJIF; @Action() public void viewExpenses() { expenseJIF = showJInternalFrame(expenseJIF, ExpenseView.class); } JInternalFrame medicationJIF; @Action public void viewMedications() { medicationJIF = showJInternalFrame(medicationJIF, MedicationView.class); } JInternalFrame vaccinationJIF; @Action public void viewVaccinations() { vaccinationJIF = showJInternalFrame(vaccinationJIF, VaccinationView.class); } JInternalFrame generalHealthNotesJIF; @Action public void viewGeneralHeathNotes() { generalHealthNotesJIF = showJInternalFrame(generalHealthNotesJIF, GeneralHealthNoteView.class); } PreferencesView preferencesView; @Action public void viewPreferences() { if (preferencesView == null) { preferencesView = new PreferencesView(this, true); preferencesView.pack(); preferencesView.setLocationRelativeTo(preferencesView.getParent()); } preferencesView.setVisible(true); } JInternalFrame serviceProviderJIF; @Action public void viewServiceProviders() { serviceProviderJIF = showJInternalFrame(serviceProviderJIF, ServiceProviderView.class); } @Action public void viewMyAccount() { if (session.getUserType() == Serviceprovider.class) { RegisterServiceProviderView.getJDialogInstance(this).setVisible(true); } if (session.getUserType() == Petsowner.class) { RegisterPetsOwnerView.getJDialogInstance(this, true).setVisible(true); } } JDialog aboutBox; @Action public void viewAboutBox() { if (aboutBox == null) { aboutBox = new AboutBox(this); aboutBox.pack(); aboutBox.setLocationRelativeTo(this); } aboutBox.setVisible(true); } JInternalFrame medicalPixJIF; JPanel medicalPixPanel; static String titleMedicallPixView = "Medical Pictures View"; @Action public void viewMedicalPix() { try { if (medicalPixPanel == null) { medicalPixPanel = new PictureView(PictureType.getMedicalPictureTypeInstance()); } medicalPixJIF = showJInternalFrame(medicalPixJIF, medicalPixPanel, titleMedicallPixView); } catch (PropertyVetoException ex) { Logger.getLogger(MDI.class.getName()).log(Level.SEVERE, null, ex); } } JInternalFrame generalPixJIF; JPanel generalPixPanel; static String titleGeneralPixView = "General Pictures View"; @Action public void viewGeneralPix() { try { if (generalPixPanel == null) { generalPixPanel = new PictureView(PictureType.getGeneralPictureTypeInstance()); } generalPixJIF = showJInternalFrame(generalPixJIF, generalPixPanel, titleGeneralPixView); } catch (PropertyVetoException ex) { Logger.getLogger(MDI.class.getName()).log(Level.SEVERE, null, ex); } } @Action public void viewEmergencyInfo() { JDialog jdg = RegisterPetsOwnerView.getJDialogInstance(this, false); jdg.setVisible(true); } JInternalFrame appointmentJIF; @Action public void viewAppointments() { appointmentJIF = showJInternalFrame(appointmentJIF, AppointmentView.class); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -