⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nistmessenger.java

📁 是一个用java实现的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * NISTMessenger.java
 *
 * Created on January 27, 2004, 6:53 PM
 */

package gov.nist.applet.phone.ua.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URL;

import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;

import gov.nist.applet.phone.media.messaging.VoiceRecorder;
import gov.nist.applet.phone.ua.ChatSessionManager;
import gov.nist.applet.phone.ua.Configuration;
import gov.nist.applet.phone.ua.RegisterStatus;
import gov.nist.applet.phone.ua.MessengerController;
import gov.nist.applet.phone.ua.MessengerManager;
import gov.nist.applet.phone.ua.StopMessenger;
import gov.nist.applet.phone.ua.presence.Subscriber;

/**
 * This application has been designed in following the MVC design pattern
 * Thus, this class is part of the View.
 * @author Jean Deruelle
 *
 * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
 */
public class NISTMessenger extends javax.swing.JFrame 
                              implements java.util.Observer, NISTMessengerGUI {
    Configuration configuration;
    /*MVC attributes*/
    private MessengerManager sipMeetingManager;
    private MessengerController controllerMeeting;        
    private ChatSessionManager chatSessionManager;	
		    
    /** Creates new form NISTMessenger */
    public NISTMessenger() {
        configuration=new Configuration();
        chatSessionManager=new ChatSessionManager();
        sipMeetingManager=new MessengerManager(configuration,this); 
        sipMeetingManager.addObserver(this);
        controllerMeeting= new MessengerController(
        		sipMeetingManager,
        		chatSessionManager,
        		this);
        initComponents();
        listModel=new DefaultListModel();
        
        //Create the list and put it in a scroll pane.
        jList1= new JList(listModel);
        jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jList1.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    String contactAddress=(String)listModel.elementAt(jList1.getSelectedIndex());
					if(contactAddress.trim().indexOf('(')!=-1)
                    	contactAddress=contactAddress.substring(
                    		0,
                    		contactAddress.trim().indexOf("("));
                    //check if a chat frame has already been opened
					ChatFrame chatFrame=(ChatFrame)chatSessionManager.getChatFrame(contactAddress);
					if(chatFrame==null){	
						//emulate button click
					  	chatFrame=new ChatFrame(
					  			this,
								contactAddress,
								sipMeetingManager,
								chatSessionManager);
					  	chatSessionManager.addChatSession(contactAddress,chatFrame);
					  	chatFrame.show();				                   
					}
					else{
						chatFrame.show();
					}                    
                }
            }
        });
        
        JScrollPane listScrollPane = new JScrollPane(jList1);
        listScrollPane.setBounds(10, 100, 200, 250);
        mainPanel.add(listScrollPane);
        getContentPane().add(mainPanel);
		// Get current classloader
   		ClassLoader cl = this.getClass().getClassLoader();
		URL url=cl.getResource("images/short_nisthome_banner.jpg");
		if(url!=null)
			imageLabel.setIcon(new ImageIcon(url));		
        this.pack();
        this.setTitle("NIST Messenger");
        this.setSize(320, 520);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        mainPanel = new javax.swing.JPanel();
        imageLabel = new javax.swing.JLabel();
        addContactButton = new javax.swing.JButton();
        removeContactButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        fileMenuBar1 = new javax.swing.JMenuBar();
        jMenu5 = new javax.swing.JMenu();
        jMenuItemConfiguration = new javax.swing.JMenuItem();
        jMenuItemRegister = new javax.swing.JMenuItem();
        jMenuItemUnregister = new javax.swing.JMenuItem();
        jMenuItemExit = new javax.swing.JMenuItem();
		jMenuStatus = new javax.swing.JMenu();

		onlineJRadioButtonMenuItem= new JRadioButtonMenuItem("Online");
		awayJRadioButtonMenuItem= new JRadioButtonMenuItem("Away");
		offlineJRadioButtonMenuItem= new JRadioButtonMenuItem("Be Right Back");
		busyJRadioButtonMenuItem= new JRadioButtonMenuItem("Busy");

        getContentPane().setLayout(null);

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        mainPanel.setLayout(null);

        mainPanel.setMinimumSize(new java.awt.Dimension(310, 500));
        mainPanel.setPreferredSize(new java.awt.Dimension(310, 500));
        imageLabel.setMaximumSize(new java.awt.Dimension(400, 50));
        imageLabel.setMinimumSize(new java.awt.Dimension(300, 50));
        imageLabel.setPreferredSize(new java.awt.Dimension(400, 50));
        mainPanel.add(imageLabel);
        imageLabel.setBounds(11, 6, 290, 50);

        addContactButton.setText("Add Contact");
        addContactButton.setOpaque(false);
        addContactButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addContactButtonActionPerformed(evt);
            }
        });

        mainPanel.add(addContactButton);
        addContactButton.setBounds(10, 400, 120, 40);

        removeContactButton.setText("Remove Contact");
        removeContactButton.setEnabled(false);
        removeContactButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeContactButtonActionPerformed(evt);
            }
        });

        mainPanel.add(removeContactButton);
        removeContactButton.setBounds(160, 400, 130, 40);

        jLabel1.setText("Not Logged");
        mainPanel.add(jLabel1);
        jLabel1.setBounds(10, 70, 290, 20);

        getContentPane().add(mainPanel);
        mainPanel.setBounds(0, 0, 310, 500);

        jMenu5.setText("Menu");
        jMenuItemConfiguration.setText("Configuration");
        jMenuItemConfiguration.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemConfigurationActionPerformed(evt);
            }
        });

        jMenu5.add(jMenuItemConfiguration);

        jMenuItemRegister.setText("Register");
        jMenuItemRegister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRegisterActionPerformed(evt);
            }
        });

        jMenu5.add(jMenuItemRegister);

        jMenuItemUnregister.setText("Unregister");
        jMenuItemUnregister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemUnregisterActionPerformed(evt);
            }
        });

        jMenu5.add(jMenuItemUnregister);

		jMenuStatus.setText("Status");
		onlineJRadioButtonMenuItem.addActionListener(new ActionListener() {
			  public void actionPerformed(ActionEvent evt) {
				 onlineActionPerformed(evt);
			  }
		  }
		);
        
		awayJRadioButtonMenuItem.addActionListener(new ActionListener() {
			  public void actionPerformed(ActionEvent evt) {
				 awayActionPerformed(evt);
			  }
		  }
		);
        
		offlineJRadioButtonMenuItem.addActionListener(new ActionListener() {
			  public void actionPerformed(ActionEvent evt) {
				beRightBackActionPerformed(evt);
			  }
		  }
		);
        
		busyJRadioButtonMenuItem.addActionListener(new ActionListener() {
			  public void actionPerformed(ActionEvent evt) {
				 busyActionPerformed(evt);
			  }
		  }
		);
		statusGroup= new ButtonGroup();
		onlineJRadioButtonMenuItem.setSelected(true);
		statusGroup.add(onlineJRadioButtonMenuItem);
		statusGroup.add(offlineJRadioButtonMenuItem);
		statusGroup.add(busyJRadioButtonMenuItem);
		statusGroup.add(awayJRadioButtonMenuItem);
        
		jMenuStatus.add(awayJRadioButtonMenuItem);
		jMenuStatus.add(onlineJRadioButtonMenuItem);
		jMenuStatus.add(offlineJRadioButtonMenuItem);
		jMenuStatus.add(busyJRadioButtonMenuItem);
			
		jMenu5.add(jMenuStatus);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -