📄 nistmessenger.java
字号:
jMenuItemExit.setText("Exit"); jMenuItemExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemExitActionPerformed(evt); } }); jMenu5.add(jMenuItemExit); fileMenuBar1.add(jMenu5); setJMenuBar(fileMenuBar1); pack(); }//GEN-END:initComponents private void jMenuItemExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExitActionPerformed // Add your handling code here: close(); }//GEN-LAST:event_jMenuItemExitActionPerformed private void jMenuItemUnregisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUnregisterActionPerformed // Add your handling code here: if(sipMeetingManager.getRegisterStatus().equalsIgnoreCase( RegisterStatus.NOT_REGISTERED)){ JOptionPane.showMessageDialog( this, "You are currently not registered, please register to un-register", "Already un-registered", JOptionPane.ERROR_MESSAGE); return; } unRegister(); controllerMeeting.undisplayAllContact(); removeContactButton.setEnabled(false); }//GEN-LAST:event_jMenuItemUnregisterActionPerformed private void jMenuItemRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRegisterActionPerformed // Add your handling code here: if(sipMeetingManager.getRegisterStatus().equalsIgnoreCase( RegisterStatus.REGISTERED)){ JOptionPane.showMessageDialog( this, "You are already registered, please un-register before", "Already registered", JOptionPane.ERROR_MESSAGE); return; } sipMeetingManager.register(); controllerMeeting.displayAllContact(); removeContactButton.setEnabled(true); }//GEN-LAST:event_jMenuItemRegisterActionPerformed private void jMenuItemConfigurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConfigurationActionPerformed // Add your handling code here: new ConfigurationFrame(sipMeetingManager).show(); }//GEN-LAST:event_jMenuItemConfigurationActionPerformed private void onlineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRegisterActionPerformed // Add your handling code here: jLabel1.setText("Logged as : "+configuration.userURI +" - Online"); sipMeetingManager.getPresentityManager(). sendNotifyToAllSubscribers("open","online"); }//GEN-LAST:event_jMenuItemRegisterActionPerformed private void busyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRegisterActionPerformed // Add your handling code here: jLabel1.setText("Logged as : "+configuration.userURI +" - Busy"); sipMeetingManager.getPresentityManager(). sendNotifyToAllSubscribers("inuse","busy"); }//GEN-LAST:event_jMenuItemRegisterActionPerformed private void awayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRegisterActionPerformed // Add your handling code here: jLabel1.setText("Logged as : "+configuration.userURI +" - Away"); sipMeetingManager.getPresentityManager(). sendNotifyToAllSubscribers("inactive","away"); }//GEN-LAST:event_jMenuItemRegisterActionPerformed private void beRightBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRegisterActionPerformed // Add your handling code here: jLabel1.setText("Logged as : "+configuration.userURI +" - Be Right Back"); sipMeetingManager.getPresentityManager(). sendNotifyToAllSubscribers("inactive","berightback"); }//GEN-LAST:event_jMenuItemRegisterActionPerformed private void removeContactButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeContactButtonActionPerformed controllerMeeting.removeContact(); }//GEN-LAST:event_removeContactButtonActionPerformed private void addContactButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addContactButtonActionPerformed // Add your handling code here: if(!sipMeetingManager.getRegisterStatus().equalsIgnoreCase( RegisterStatus.REGISTERED)){ JOptionPane.showMessageDialog( this, "You must be registered to add a new contact", "Contact Error", JOptionPane.ERROR_MESSAGE); return; } String contactAddress = (String)JOptionPane.showInputDialog( this, "Enter the contact address to add:\n", "Add Contact", JOptionPane.PLAIN_MESSAGE, null, null, null); if(contactAddress!=null){ if(contactAddress.indexOf("@")!=-1){ Subscriber subscriber=new Subscriber(contactAddress); sipMeetingManager.getPresentityManager().addSubscriber(subscriber); sipMeetingManager.sendSubscribe(contactAddress); controllerMeeting.addContact(contactAddress); } else{ JOptionPane.showMessageDialog( this, "The contact must be of the form user@domain" + ", the contact has not been added", "Contact Error", JOptionPane.ERROR_MESSAGE); } } }//GEN-LAST:event_addContactButtonActionPerformed /** * Get the view component representing the logged status label * @return the logged status label */ public JLabel getLoggedStatusLabel() { return jLabel1; } /** * Get the contact list from this frame * @return the contact list from this frame */ public JList getContactList(){ return jList1; } /** * Get the contact list from this frame * @return the contact list from this frame */ public JButton getRemoveContactButton(){ return removeContactButton; } /** * */ public void update(java.util.Observable o, Object arg) { } /** * Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm close(); }//GEN-LAST:event_exitForm /** * * */ private void close(){ unRegister(); if(!VoiceRecorder.isClosed()) VoiceRecorder.getInstance().close(); new StopMessenger(sipMeetingManager.getMessageListener()); //System.exit(0); } /** * * */ protected void unRegister(){ if(sipMeetingManager.getRegisterStatus().equalsIgnoreCase( RegisterStatus.REGISTERED)){ if(chatSessionManager.hasActiveSessions()){ int response=javax.swing.JOptionPane.showConfirmDialog(null, " All current sessions will be closed,\n" + " do you still want to close the application ?", "Close the Application", javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); if(response==javax.swing.JOptionPane.NO_OPTION) return; else if(response==javax.swing.JOptionPane.YES_OPTION){ chatSessionManager.closeAllSessions(); } } sipMeetingManager.unRegister(); } } /** Fatal error. */ public void fatalError(String errorText) { JOptionPane.showMessageDialog( this, errorText, "Fatal Error", JOptionPane.ERROR_MESSAGE); close(); } /** * @param args the command line arguments */ public static void main(String args[]) { new NISTMessenger().show(); } /** * GUI variables. */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addContactButton; private javax.swing.JMenuBar fileMenuBar1; private javax.swing.JLabel imageLabel; private javax.swing.JLabel jLabel1; private javax.swing.JMenu jMenu5; private javax.swing.JMenuItem jMenuItemConfiguration; private javax.swing.JMenuItem jMenuItemRegister; private javax.swing.JMenuItem jMenuItemUnregister; private javax.swing.JMenuItem jMenuItemExit; private javax.swing.JMenu jMenuStatus; private javax.swing.JPanel mainPanel; private javax.swing.JButton removeContactButton; // End of variables declaration//GEN-END:variables private javax.swing.JList jList1; private DefaultListModel listModel; private JRadioButtonMenuItem onlineJRadioButtonMenuItem; private JRadioButtonMenuItem awayJRadioButtonMenuItem; private JRadioButtonMenuItem offlineJRadioButtonMenuItem; private JRadioButtonMenuItem busyJRadioButtonMenuItem; ButtonGroup statusGroup; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -