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

📄 jicq.java

📁 类似QQ一个用java开发出来的聊天工具
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    tel = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("addr"))
                    addr = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("http"))
                    http = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("mobile"))
                    mobile = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("email"))
                    email = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("pass"))
                    pass = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("check"))
                    check = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("age"))
                    age = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("ip"))
                    ip = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("statu"))
                    statu = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("integral"))
                    integral = inline.substring(inline.indexOf(' ') + 1);
            }
            while (!inline
                .substring(0, inline.indexOf(' '))
                .equalsIgnoreCase("end"));
        }
        catch (Exception e)
        {
            System.out.println("  MainFrame getID() string error:" + e);
        }
        icqid.nick = nick;
        //icqid.pass=pass;
        icqid.info = info;
        icqid.sex = sex;
        icqid.tel = tel;
        icqid.mobile = mobile;
        icqid.http = http;
        icqid.email = email;
        icqid.addr = addr;
        icqid.age = age;
        icqid.picNo = picNo;
        icqid.check = check;
        icqid.integral = integral;
        if (statu.equals("1"))
        {
            icqid.isOnline = true;
            try
            {
                String rport;
                rport = ip.substring(ip.lastIndexOf(":") + 1);
                ip = ip.substring(0, ip.indexOf(":"));
                icqid.ip = ip;
                icqid.rport = rport;
            }
            catch (Exception e)
            {
            }
        }
        return icqid;
    }
    static String replace(String s1, String s2, String s3)
    {
        if (s1 == null || s2 == null || s3 == null)
            return s1;
        try
        {
            while (-1 != s1.indexOf(s2))
            {
                s1 =
                    s1.substring(0, s1.indexOf(s2))
                        + s3
                        + s1.substring(s1.indexOf(s2) + s2.length());
            }
        }
        catch (Exception e)
        {
            System.out.println("  replace() error:" + s1);
        }
        return s1;
    }
    void toID(String s)
    {
        //System.out.println("  toID() Received:\n"+s+"**");
        if (s.equals(""))
            return;
        s += " ";
        IcqID icqid;

        String no, ip;
        try
        {
            while (s.indexOf("\n") != -1)
            {
                no = s.substring(0, s.indexOf(' '));
                s = s.substring(s.indexOf(' ') + 1);
                ip = s.substring(0, s.indexOf("\n"));
                s = s.substring(s.indexOf("\n") + 1);
                icqid = (IcqID) friend.get(no);
                if (icqid != null)
                {
                    icqid.isOnline = true;
                    icqid.ip = ip.substring(0, ip.indexOf(':'));
                    icqid.rport = ip.substring(ip.lastIndexOf(':') + 1);
                    setFriend(no, icqid);
                }
            }
        }
        catch (Exception e)
        {
            System.out.println("  error in getOnline():" + e);
        }
    }

    void delFriend()//删除好友方法
    {
        if (currenticqid == null)
            return;
        if (currenticqid.isStranger)
        {
            friend.remove(currenticqid.icqNo);
            repaintEvt = true;
            return;
        }
        Sender s =
            new Sender(
                "DELFRIEND icqNo:"
                    + myIcqID.icqNo
                    + " del:"
                    + currenticqid.icqNo);
        s.start();
        Result r = s.getReturn();
        if (r.getCode() == 200)
        {
            currenticqid.stopRun = true;
            friend.remove(currenticqid.icqNo);
            repaintEvt = true;
            noteMsg("删除" + currenticqid.getNick() + "成功。");
        }
        else
            noteMsg("删除" + currenticqid.getNick() + "失败:" + r.getMsg());
    }
    void sendTo()//发送信息方法
    {
        if (currenticqid != null)
        {
            if (currenticqid.smsg == null || !currenticqid.smsg.isValid())
            {
                currenticqid.smsg = new SMsg(currenticqid, myIcqID);
                currenticqid.clearNew();
                //repaint();
            }
            else
            {
                currenticqid.smsg.toFront();
            }
        }
    }
    protected void processWindowEvent(WindowEvent e)
    {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING)
        {
            close();
            return;
        }
    }
    protected void processKeyEvent(KeyEvent evt)
    {
        super.processKeyEvent(evt);
        if (evt.getKeyCode() == KeyEvent.VK_F4)
        {
            Enumeration e = friend.keys();
            currenticqid = null;
            IcqID icqid = null;
            while (e.hasMoreElements())
            {
                icqid = (IcqID) friend.get((String) e.nextElement());
                if (icqid != null)
                    if (icqid.newMsg)
                    {
                        currenticqid = icqid;
                    }
            }
            sendTo();
        }
    }
    protected void processMouseMotionEvent(MouseEvent e)
    {
        super.processMouseMotionEvent(e);
        if (!LOGED)
            return;
        if (e.getID() == MouseEvent.MOUSE_MOVED)
            mouseMoved(e.getX(), e.getY());
    }
    public void mouseMoved(int x, int y)
    {
        try
        {
            currentarea = getArea(x, y);
            Graphics g = getGraphics();
            int zoom = 0;

            if (currentarea == 4)
            {
                Enumeration e = friend.keys();
                IcqID icqid = null;
                while (e.hasMoreElements())
                {
                    icqid = (IcqID) friend.get((String) e.nextElement());
                    if (icqid.index >= 0 && icqid.index < icqid.canShow)
                        if (icqid.top < y && icqid.bottom > y)
                            icqid.mouseEnter(this);
                        else
                            icqid.mouseExit(this);
                }
            }
            if (pastarea == currentarea || currentarea == -1)
                return;
            g.setColor(getBackground());
            if (pastarea <= area.length)
                for (int i = 0; i < area.length; i++)
                    if (i != 4)
                        g.drawRect(
                            area[i][0],
                            area[i][1] + zoom,
                            area[i][2] - area[i][0] - 1,
                            area[i][3] - area[i][1] - zoom);
            g.setColor(new Color(SysInfo.textcolor));
            pastarea = currentarea;
            if (currentarea == 4)
                return;
            g.drawRect(
                area[currentarea][0],
                area[currentarea][1] + zoom,
                area[currentarea][2] - area[currentarea][0] - 1,
                area[currentarea][3] - area[currentarea][1] - zoom);
        }
        catch (Exception e)
        {
        }
    }

    protected void processMouseEvent(MouseEvent e)
    {
        super.processMouseEvent(e);
        if (!LOGED)
            return;
        if (e.getID() == MouseEvent.MOUSE_PRESSED)
            mousePressed(e, e.getX(), e.getY());
        if (e.getID() == MouseEvent.MOUSE_CLICKED)
            mouseClicked(e, e.getX(), e.getY());
        if (e.isPopupTrigger())
            popupMenu(e, e.getX(), e.getY()); //right button
    }
    void popupMenu(MouseEvent evt, int x, int y)
    {
        int ca = getArea(x, y);
        IcqID icqid = null;
        switch (ca)
        {
            case 4 :
                pm.show(this, x, y);
                Enumeration e = friend.keys();
                //System.out.println("  more="+e.hasMoreElements());
                while (e.hasMoreElements())
                {
                    icqid = (IcqID) friend.get((String) e.nextElement());
                    if (icqid.index >= 0 && icqid.index < icqid.canShow)
                        if (icqid.top < y && icqid.bottom > y)
                        {
                            currenticqid = icqid;
                        }
                }
                //System.out.println("  currenticqid.icqNo="+currenticqid.icqNo);
                break;
            case 9 :
                modifyPM.show(this, area[9][2], area[9][1]);
                break;
            default :
                }
    }
    public void mouseClicked(MouseEvent evt, int x, int y)
    {
        //System.out.println("   MouseClicked..."+evt.getClickCount());
        if (evt.getClickCount() == 2)
        {
            Enumeration e = friend.keys();
            currenticqid = null;
            IcqID icqid = null;
            while (e.hasMoreElements())
            {
                icqid = (IcqID) friend.get((String) e.nextElement());
                if (icqid.index >= 0 && icqid.index < icqid.canShow)
                    if (icqid.top < y && icqid.bottom > y)
                    {
                        currenticqid = icqid;
                    }
            }
            //System.out.println("  currenticqid.icqNo="+currenticqid.icqNo);
            if (currenticqid != null)
                sendTo();
        }

        return;
    }
    public void mousePressed(MouseEvent evt, int x, int y)
    {
        //System.out.println(" the l,m,r="+evt.modifiers);
        if (!LOGED)
            return;
        mouseMoved(x, y);
        int ca = getArea(x, y);
        if (ca == -1)
            return;
        int min = 0, max = 0;
        Enumeration e = friend.keys();
        IcqID icqid = null;
        for (; e.hasMoreElements();)
        {
            icqid = (IcqID) friend.get((String) e.nextElement());
            if (icqid.index < min)
            {
                min = icqid.index;
            }
            if (icqid.index > max)
            {
                max = icqid.index;
            }
        }
        int canShow = 0;
        if (icqid != null)
            canShow = icqid.canShow;
        String icqNo = null;
        currenticqid = null;

        if (!evt.isPopupTrigger()) //left button
        {
            int add = 0;
            switch (ca)
            {
                case 0 :
                    Runtime r0 = Runtime.getRuntime();
                    try
                    {
                        r0.exec("explorer http://jicq.vicp.net/bbs ");
                    }
                    catch (Exception exp)
                    {
                    }
                    break;
                case 1 :
                    Runtime r1 = Runtime.getRuntime();
                    try
                    {
                        r1.exec("explorer http://jicq.vicp.net/reg/reg.htm ");
                    }
                    catch (Exception exp)
                    {
                    }
                    break;
                case 2 :
                    Runtime r2 = Runtime.getRuntime();
                    try
                    {
                        r2.exec("explorer http://jicq.vicp.net ");
                    }
                    catch (Exception exp)
                    {
                    }
                    break;
                case 3 :
                    help();
                    break;
                case 4 :
                    break;

⌨️ 快捷键说明

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