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

📄 jim.java

📁 100%Java编写及时报信工具
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
package jim;

import java.awt.event.*;
import java.util.*;
import javax.swing.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
/* Copyright, 2001 Jason Dominiczak.
 *
 * This file is part of JIM - The Java Instant Messenger.
 * eMailer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.

 * JIM is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with eMailer; see the file COPYING. If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA.
 */
public class Jim extends JFrame implements TreeSelectionListener {
	private JMenuItem ivjAbout_BoxMenuItem = null;
	IvjEventHandler ivjEventHandler = new IvjEventHandler();
	private JMenuItem ivjExitMenuItem = null;
	private JMenu ivjFileMenu = null;
	private JMenu ivjHelpMenu = null;
	private JPanel ivjJFrameContentPane = null;
	private JMenuBar ivjJimJMenuBar = null;
	private JPanel ivjJimPane = null;
	private JMenuItem ivjNew_Instant_MessageMenuItem = null;
	private JPanel ivjStatusBarPane = null;
	private JLabel ivjStatusMsg1 = null;
	private JMenuItem ivjJMenuItem1 = null;
	private JSeparator ivjJSeparator1 = null;
	public javax.swing.tree.DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode("root");//$NON-NLS-1$
	private JTree ivjBuddyList = null;
	private JScrollPane ivjJScrollPane1 = null;
	public javax.swing.tree.DefaultTreeCellRenderer treeRenderer;
	private PluginLoader ivjPluginLoader = null;
	private static java.util.ResourceBundle resuser = java.util.ResourceBundle.getBundle("user"); //$NON-NLS-1$;
	private InstantMessage ivjInstantMessageWindow = null;
	private JMenuItem ivjJMenuItem2 = null;
	public DefaultTreeModel BuddyTreeModel;
	private JButton ivjDefaultToolBarButton = null;
	private JComboBox ivjJComboBox1 = null;
	private JPanel ivjJDialogContentPane = null;
	private JEditorPane ivjJEditorPane1 = null;
	private JLabel ivjJLabel1 = null;
	private JPanel ivjJPanel1 = null;
	private JScrollPane ivjJScrollPane2 = null;
	private JToolBar ivjJToolBar1 = null;
	private JFrame ivjIMDialog = null;
	private JTextField ivjIMToField = null;
	public boolean modingTree = false;
	private JMenuItem ivjProperties = null;
	private JMenuItem ivjJMenuItem3 = null;

class IvjEventHandler implements java.awt.event.ActionListener {
		public void actionPerformed(java.awt.event.ActionEvent e) {
			if (e.getSource() == Jim.this.getExitMenuItem()) 
				connEtoM1(e);
			if (e.getSource() == Jim.this.getAbout_BoxMenuItem()) 
				connEtoC1(e);
			if (e.getSource() == Jim.this.getJMenuItem1()) 
				connEtoC2(e);
			if (e.getSource() == Jim.this.getJMenuItem2()) 
				connEtoC4(e);
			if (e.getSource() == Jim.this.getProperties()) 
				connEtoC5(e);
			if (e.getSource() == Jim.this.getJMenuItem3()) 
				connEtoC7(e);
			if (e.getSource() == Jim.this.getDefaultToolBarButton()) 
				connEtoC6(e);
			if (e.getSource() == Jim.this.getNew_Instant_MessageMenuItem()) 
				connEtoM6(e);
		};
	};
/**
 * Jim constructor comment.
 */
public Jim() {
	super();
	initialize();
}
/**
 * Jim constructor comment.
 * @param title java.lang.String
 */
public Jim(String title) {
	super(title);
}
/**
 * Insert the method's description here.
 * Creation date: (10/26/2001 4:49:25 PM)
 * @param buddySN java.lang.String
 * @param plInterface jim.PluginInterface
 */
public void addBuddyToTree(String buddySN, PluginInterface plInterface) {
    while (modingTree == true) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException ie) {
        };
    }
    modingTree = true;
    DefaultTreeModel dtm = ((DefaultTreeModel) getBuddyList().getModel());
    DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(buddySN);
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) dtm.getRoot();
    DefaultMutableTreeNode child = null;
    for (int i = 0; i < node.getChildCount(); i++) {
        if (node.getChildAt(i).toString() == plInterface.getTreeName()) {
            child = (DefaultMutableTreeNode) node.getChildAt(i);
            child.add(newNode);
            //((DefaultTreeModel)getBuddyList().getModel()).insertNodeInto(newNode, child, 0);
            //getBuddyList().getModel().
        }
    }
    //node.add(newNode);
     ((DefaultTreeModel) getBuddyList().getModel()).nodeStructureChanged(child);
    PluginLoader pLoader = getPluginLoader();
    PluginInterface[] pInterface = pLoader.getPlugins();
    for (int i = 0; i < pInterface.length; i++) {
        getBuddyList().expandPath(getBuddyList().getPathForRow(i));
        //		rootnode.add(tNode);
    }

    //((DefaultTreeModel)getBuddyList().getModel()).reload(child);
    //((DefaultTreeModel)getBuddyList().getModel()).reload(node);
    //getBuddyList().scrollPathToVisible(new TreePath(child.getPath()));
    //((DefaultTreeModel) getBuddyList().getModel()).reload();
    //getBuddyList().updateUI();
    //getBuddyList().repaint();

    //((DefaultTreeModel)getBuddyList().getModel()).reload(child);
    //BuddyTreeModel.nodeStructureChanged(node);
    //getBuddyList().setModel(BuddyTreeModel);
    //dtm.reload();
    modingTree = false;
}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyAway(String buddySN, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyBack(String buddySN, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyOff(String buddySN, PluginInterface plInterface) {
	removeBuddyFromTree(buddySN, plInterface);
	
	}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyOn(String buddySN, PluginInterface plInterface) {
	addBuddyToTree(buddySN, plInterface);
	}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param error int
 */
public void callbackDisconnect(int error, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param error int
 */
public void callbackError(int error, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 * @param idle long
 */
public void callbackGotIdle(String buddySN, long idle, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 * @param info java.lang.String
 * @param warning int
 * @param idle int
 * @param flags int
 */
public void callbackGotInfo(String buddySN, String info, int warning, int idle, int flags, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param level int
 * @param buddySN java.lang.String
 */
public void callbackGotWarned(int level, String buddySN, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param buddySN java.lang.String
 * @param online int
 * @param away int
 */
public void callbackListBuddy(String buddySN, int online, int away, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (11/24/2001 10:34:31 PM)
 */
public void callbackLoggedOff(PluginInterface plInterface) {
	while(modingTree==true){
	 	try {
				Thread.sleep(500);
		} catch (InterruptedException ie) {};
 	}
	modingTree=true;
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)	getBuddyList().getModel().getRoot();
	for(int i=0;i<node.getSiblingCount();i++)
	{
		if(node.getChildAt(i).toString()==plInterface.getTreeName())
		{
			DefaultMutableTreeNode child = (DefaultMutableTreeNode)	node.getChildAt(i);
			//child.add(newNode);
			//BuddyTreeModel.insertNodeInto(newNode, child, 0);
			child.removeAllChildren();
			((DefaultTreeModel) getBuddyList().getModel()).nodeStructureChanged(child);
		}
	}
	modingTree=false;
	}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param who java.lang.String
 * @param text java.lang.String
 * @param automessage int
 */
public void callbackRecievedMessage(String who, String text, PluginInterface plInterface) {
	if(getInstantMessageWindow().isVisible()==false){
		getInstantMessageWindow().setVisible(true);
	}
	getInstantMessageWindow().newInstantMessage(who, text, plInterface);
}
/**
 * Insert the method's description here.
 * Creation date: (10/15/2001 4:00:09 PM)
 * @param idle long
 */
public void callbackSetIdle(long idle, PluginInterface plInterface) {}
/**
 * Insert the method's description here.
 * Creation date: (10/16/2001 6:57:11 PM)
 * @param username java.lang.String
 * @param password java.lang.String
 * @param plInterface jim.PluginInterface
 */
public void connect(String username, String password, PluginInterface plInterface) {
	//plInterface.setJim(this);//added
	plInterface.login();
	}
/**
 * Insert the method's description here.
 * Creation date: (10/16/2001 6:57:11 PM)
 * @param username java.lang.String
 * @param password java.lang.String
 * @param plInterface jim.PluginInterface
 */
public void connect(PluginInterface plInterface) {
	//plInterface.setJim(this);//added
	plInterface.login();
	}
/**
 * connEtoC1:  (About_BoxMenuItem.action.actionPerformed(java.awt.event.ActionEvent) --> Jim.showAboutBox()V)
 * @param arg1 java.awt.event.ActionEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC1(java.awt.event.ActionEvent arg1) {
	try {
		// user code begin {1}
		// user code end
		this.showAboutBox();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
}
/**
 * connEtoC2:  (JMenuItem1.action.actionPerformed(java.awt.event.ActionEvent) --> Jim.showPluginManager()V)
 * @param arg1 java.awt.event.ActionEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC2(java.awt.event.ActionEvent arg1) {
	try {
		// user code begin {1}
		// user code end
		this.showPluginManager();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
}
/**
 * connEtoC3:  (Jim.initialize() --> Jim.jim_WindowActivated()V)
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC3() {
	try {
		// user code begin {1}
		// user code end
		this.jim_WindowActivated();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
}
/**
 * connEtoC4:  (JMenuItem2.action.actionPerformed(java.awt.event.ActionEvent) --> Jim.loginAll()V)
 * @param arg1 java.awt.event.ActionEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC4(java.awt.event.ActionEvent arg1) {
	try {
		// user code begin {1}
		// user code end
		this.loginAll();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
}
/**
 * connEtoC5:  (Properties.action.actionPerformed(java.awt.event.ActionEvent) --> Jim.showProperties()V)
 * @param arg1 java.awt.event.ActionEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC5(java.awt.event.ActionEvent arg1) {
	try {
		// user code begin {1}
		// user code end
		this.showProperties();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
}
/**
 * connEtoC6:  (DefaultToolBarButton.action.actionPerformed(java.awt.event.ActionEvent) --> Jim.SendIM(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)V)
 * @param arg1 java.awt.event.ActionEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC6(java.awt.event.ActionEvent arg1) {
	try {
		// user code begin {1}
		// user code end
		this.SendIM((String)getJComboBox1().getSelectedItem(), getIMToField().getText(), getJEditorPane1().getText());
		connEtoM4();
		connEtoM3();
		connEtoM5();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
}
/**
 * connEtoC7:  (JMenuItem3.action.actionPerformed(java.awt.event.ActionEvent) --> Jim.logoffAll()V)
 * @param arg1 java.awt.event.ActionEvent
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC7(java.awt.event.ActionEvent arg1) {
	try {
		// user code begin {1}
		// user code end
		this.logoffAll();
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end

⌨️ 快捷键说明

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