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

📄 nistmessengerapplet.java

📁 是一个用java实现的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		awayJRadioButtonMenuItem = new JRadioButtonMenuItem("Away");
		offlineJRadioButtonMenuItem = new JRadioButtonMenuItem("Be Right Back");
		busyJRadioButtonMenuItem = new JRadioButtonMenuItem("Busy");

		getContentPane().setLayout(null);

		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);

		fileMenuBar1.add(jMenu5);

		setJMenuBar(fileMenuBar1);

	} //GEN-END:initComponents

	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.unRegisterAndReRegister();
		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 contact list from this frame
	 * @return the contact list from this frame
	 */
	public JList getContactList() {
		return jList1;
	}

	/**
	 * 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 JButton getRemoveContactButton() {
		return removeContactButton;
	}

	public boolean useResponder() {
		return useResponder;
	}

	/**     
	 *
	 */
	public boolean checkForJMF() {
		Class clz;

		//Check for basic JMF class.
		try {
			Class.forName("javax.media.Player");
		} catch (Throwable throwable2) {
			return false;
		}
		return true;
	}

	/**
	 * Return the cookie with the contacts
	 * @return the string representing the contacts
	 */
	/*public String getCookieContacts(){
		if(document!=null){
			return (String)document.getMember("cookie");
		}
		else
			return null;
	}*/

	/**
	 * Store the contacts into a cookie
	 */
	/*public void storeContactsInCookie(){
		Vector contacts=sipMeetingManager.getContactList();
		String cookieContacts="";
		for(int i=0;i<contacts.size();i++){
			cookieContacts+="contact"+i+"="+(String)contacts.get(i)+";";			
		}
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.MONTH, 1);	 // Setting the calendar to one year ahead			
		String cookie=cookieContacts+" expires="+calendar.getTime().toString();			
		System.out.println("Setting the cookie for the contacts: "+cookie);
		//document.removeMember("cookie");						
		document.setMember( "cookie" ,  cookie);
	} */

	/**
	 * Parse the cookie String into a List of contacts 
	 * @param cookieContact -  the cookie string containing the contacts
	 * @return list of contacts
	 */
	public Vector parseCookieContacts(String cookieContact) {
		if (cookieContact == null || cookieContact.length() < 1) {
			return null;
		} else {
			Vector contacts = new Vector();
			StringTokenizer st = new StringTokenizer(cookieContact, ";");
			while (st.hasMoreTokens()) {
				String contact = st.nextToken();
				if (contact.indexOf("contact") != -1) {
					if (contact.indexOf("=") != -1) {
						contact = contact.substring(contact.indexOf("=") + 1);
						System.out.println(
							"Contact found in the cookie= " + contact);
						contacts.addElement(contact);
					}
				}
			}
			return contacts;
		}
	}

	/** Show a message in a dialog box and die.
	 */
	public void fatalError(String errorText) {
		JOptionPane.showMessageDialog(this, errorText);
		this.destroy();
	}
}

⌨️ 快捷键说明

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