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

📄 jicq.java

📁 类似QQ一个用java开发出来的聊天工具
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    repaintEvt = true;
            }
            if (txt.equals(mis[5]))
            {
                SysInfo.bigIcon = true;
                reSort();
                repaint();
            }
            if (txt.equals(mis[6]))
            {
                SysInfo.bigIcon = false;
                reSort();
                repaint();
            }
            if (txt.equals(mis[7]))
            {
                if (!seek.isShowing())
                    seek.setVisible(true);
                else
                    seek.toFront();
            }
            if (txt.equals(modifymis[0]))
            {
                IcqID i = getID(myIcqID);
                if (submitid == null || !submitid.isValid())
                    submitid = new SubmitID(myIcqID, "修改个人资料", true, true);
                else
                    submitid.toFront();
            }
            if (txt.equals(modifymis[1]))
            {
                if (!sysinfo.isShowing())
                    sysinfo.setVisible(true);
                else
                    sysinfo.toFront();
            }
        }
        catch (Exception e)
        {
        }
    }
    void checkID()
    {
        boolean exitfor = false;
        IcqID icqid = null;
        Enumeration en = friend.keys();
        NEWMSG = false;
        for (; en.hasMoreElements() && !exitfor;)
        {
            String no = (String) en.nextElement();
            icqid = (IcqID) friend.get(no);
            if (icqid != null)
            {
                if (icqid.newMsg)
                    NEWMSG = true; //if have new Msg then let NEWMSG=true;
                if (!icqid.checked)
                {
                    icqid = getID(icqid);
                    if (icqid != null)
                    {
                        icqid.setStranger(myIcqID.icqNo);
                        setFriend(no, icqid);
                        if (!icqid.isOnline
                            || icqid.index < 0
                            || icqid.index > icqid.canShow)
                            repaintEvt = false;
                    }
                    exitfor = true;
                } //end if,NoChecked
            } //end if ,null
        } //end for
        if (NEWMSG || message.size() > 0)
            changeImg();
        else
        {
            if (!icqShowing)
                setIconImage(jICQ.icqImage);
            icqShowing = true;
        }
    }
    void changeImg()
    {
        int blink = 400;
        long thisTime = new Date().getTime();
        Image img = null;
        if (lastShowTime + blink < thisTime && icqShowing)
        {
            img = jICQ.mailImage;
            icqShowing = false;
            lastShowTime = thisTime;
            setIconImage(img);
        }
        if (lastShowTime + blink < thisTime && !icqShowing)
        {
            img = jICQ.icqImage;
            icqShowing = true;
            lastShowTime = thisTime;
            setIconImage(img);
        }

    }
    void close()
    {
        try
        {
            jICQ.exitSystem = true;
            System.out.println("  end jICQ.");
            setVisible(false);

            String cmd = "LOGOUT icqNo:" + myIcqID.icqNo;
            Sender s = onlineMon = new Sender(cmd);
            s.start();
            Result r = s.getReturn();

            jICQ.logonOK = false;
            sysinfo.write();
            //udpRSocket.close();
            dispose();
        }
        catch (Exception e)
        {
            System.out.println("   MainFrame.close() error:" + e);
        }
        System.exit(0);
    }
    void exitMsg(String s)
    {
        diaFrame = new Dialog(new Frame(), "jICQ:严重错误:", true);
        diaFrame.setResizable(false);

        diaFrame.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                diaFrame.dispose();
                close();
            }
        });
        diaFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
        diaFrame.setBounds(200, 150, 300, 200);
        TextArea ta = new TextArea(s, 8, 30, TextArea.SCROLLBARS_VERTICAL_ONLY);
        ta.setEditable(false);
        diaFrame.add(ta);
        diaFrame.setBackground(new Color(13947080));
        Button b = new Button("确定");
        b.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                diaFrame.dispose();
                close();
            }
        });
        diaFrame.add(b);
        diaFrame.pack();
        diaFrame.setVisible(true);
    }
    void noteMsg(String s)
    {
        if (diaFrame != null)
            if (diaFrame.isValid())
                diaFrame.dispose();
        diaFrame = new Dialog(new Frame(), "jICQ信息:", true);
        diaFrame.setResizable(false);

        diaFrame.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                diaFrame.dispose();
            }
        });
        diaFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
        diaFrame.setBounds(200, 150, 200, 150);
        TextArea ta = new TextArea(s, 6, 30, TextArea.SCROLLBARS_VERTICAL_ONLY);
        ta.setEditable(false);
        diaFrame.add(ta);
        diaFrame.setBackground(new Color(13947080));
        Button b = new Button("确定");
        b.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                diaFrame.dispose();
            }
        });
        diaFrame.add(b);
        diaFrame.pack();
        diaFrame.setVisible(true);
    }
    void joinedFrame(String s)
    {
        if (diaFrame != null)
            if (diaFrame.isValid())
                diaFrame.dispose();
        joinedIcqNo = s.substring(s.indexOf("icqNo:") + 6);
        joinedIcqNo = joinedIcqNo.substring(0, joinedIcqNo.indexOf(' '));
        diaFrame = new Dialog(new Frame(), "jICQ消息", true);
        diaFrame.setResizable(false);

        diaFrame.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                diaFrame.dispose();
            }
        });
        diaFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
        diaFrame.setBounds(200, 150, 200, 150);
        TextArea ta = new TextArea(s, 6, 30, TextArea.SCROLLBARS_VERTICAL_ONLY);
        ta.setEditable(false);
        diaFrame.add(ta);
        diaFrame.setBackground(new Color(13947080));
        String bADDs = "同意", bDISs = "拒绝";
        Button bADD = new Button(bADDs);
        bADD.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                diaFrame.dispose();
                joined();
            }
        });
        Button bDIS = new Button(bDISs);
        bDIS.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                diaFrame.dispose();
            }
        });
        diaFrame.add(bADD);
        diaFrame.add(bDIS);
        diaFrame.pack();
        diaFrame.setVisible(true);
    }
    void joined()
    {
        Sender s =
            new Sender(
                "JOINED icqNo:" + myIcqID.icqNo + " join:" + joinedIcqNo);
        s.start();
        Result r = s.getReturn();
        if (r.getCode() != 200)
            noteMsg(r.getMsg());
        else
        {
            IcqID icqid = new IcqID();
            icqid.icqNo = joinedIcqNo;
            setFriend(icqid.icqNo, icqid);
            repaintEvt = true;
        }
    }
    public static void setFriend(String key, Object value)
    {
        friend.put(key, value);
        repaintEvt = true;
    }
    public static IcqID getFriend(String key)
    {
        return (IcqID) friend.get(key);
    }

    public static void setMessage(String obj) //add system message
    {
        if (obj.indexOf(' ') == -1)
            obj += " ";
        if (obj.substring(0, obj.indexOf(' ')).equals("DUPLOGON"))
            duplogon = true;
        else
            message.insertElementAt(obj, 0);
        repaintEvt = true;
        jICQ.audioPlay(2);
    }

    void reSort()
    {
        Enumeration e = friend.keys();
        IcqID icqid;
        int startIndex = 0;
        for (; e.hasMoreElements();)
        {
            String icqNo = (String) e.nextElement();
            icqid = (IcqID) friend.get(icqNo);
            if (icqid.isOnline)
            {
                icqid.index = startIndex++;
                friend.put(icqNo, icqid);
            }
        }
        e = friend.keys();
        for (; e.hasMoreElements();)
        {
            String icqNo = (String) e.nextElement();
            icqid = (IcqID) friend.get(icqNo);
            if (!icqid.isOnline)
            {
                icqid.index = startIndex++;
                friend.put(icqNo, icqid);
            }
            //System.out.println("  icqNo="+icqid.icqNo+" ,index"+icqid.index);
        }
    }

    void toHash(String s)
    {
        String no;
        System.out.println("  toHash() Received:" + s);
        if (s.equals(""))
            return;
        try
        {
            s = s.trim();
            if (s.equals(","))
                return;
            s = s.substring(1, s.length());
            while (s.indexOf(',') != -1)
            {
                IcqID icqid = new IcqID();
                no = s.substring(0, s.indexOf(','));
                s = s.substring(s.indexOf(',') + 1);
                icqid.icqNo = no;
                setFriend(no, icqid);
                //System.out.println("  No="+no);
            }
        }
        catch (Exception e)
        {
            System.out.println("  error in toHash():" + e);
        }
    }

    static IcqID getID(IcqID in)
    {
        in.checked = true;
        //System.out.println("  getID() ");
        IcqID icqid = null;
        if (in == null)
            return null;
        else
            icqid = in;
        if (in.icqNo == null)
            return null;

        Sender sender = new Sender("GETID icqNo:" + icqid.icqNo);
        sender.start();
        Result r = sender.getReturn(5);
        if (r.getCode() != 200)
        {
            return null;
        }
        String icqids = r.getMsg();
        String inline = null;
        String nick = null,
            sex = null,
            picNo = "1",
            info = null,
            tel = null,
            addr = null,
            age = "20",
            check = "否";
        String http = null,
            mobile = null,
            email = null,
            pass = null,
            ip = null,
            statu = null,
            integral = null;
        try
        {
            do
            {
                inline = icqids.substring(0, icqids.indexOf("\n"));
                icqids = icqids.substring(icqids.indexOf("\n") + 1);
                //System.out.println("  getID() received="+inline);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("nick"))
                    nick = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("sex"))
                    sex = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("picNo"))
                    picNo = inline.substring(inline.indexOf(' ') + 1);
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("info"))
                    info = inline.substring(inline.indexOf(' ') + 1);
                info = replace(info, "\r", "\n");
                if (inline
                    .substring(0, inline.indexOf(' '))
                    .equalsIgnoreCase("tel"))

⌨️ 快捷键说明

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