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

📄 bsjidlabel.java

📁 一款即时通讯软件
💻 JAVA
字号:
package edu.ou.kmi.buddyspace.gui;

/*
 * BSJIDLabel.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2002
 *
 *
 * Created on 19 August 2002, 9:41
 */

import javax.swing.*;

import org.jabber.jabberbeans.util.*;
import edu.ou.kmi.buddyspace.core.BSPresenceInfo;

/**
 * <code>BSJIDLabel</code> is a icon label for specified JID.
 * It is meant to display presence specific icon and tooltip including
 * JID's nick name and JID string representation.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class BSJIDLabel extends JLabel {

    private JID jid = null;
    private String nick;
    //private String toolTipText = null;

    public final static Icon onlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_online.gif"));
    public final static Icon offlineIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_offline.gif"));
    public final static Icon awayIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_away.gif"));
    public final static Icon lurkerIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_lurker.gif"));
    public final static Icon clusterIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_cluster.gif"));
    public final static Icon xaIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_xa.gif"));
    public final static Icon dndIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_dnd.gif"));
    public final static Icon chatIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_chat.gif"));
    public final static Icon busyIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_busy.gif"));
    public final static Icon elseIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_swoosh.gif"));
    public final static Icon myselfIcon = new ImageIcon(ClassLoader.getSystemResource("images/map_myself.gif"));
    public final static Icon [] icons = {
            onlineIcon, offlineIcon, awayIcon, lurkerIcon, clusterIcon, xaIcon,
            dndIcon, chatIcon, busyIcon, elseIcon, myselfIcon
    };

    /** Returns icon for given presence */
    public static Icon getIconForPresence(BSPresenceInfo pi) {
        if (pi == null)
            return offlineIcon;
        else if (pi.isMyself())
            return myselfIcon;
        else if (!pi.isOnline())
            return offlineIcon;

        else if (pi.getShow() == null ||
                 BSPresenceInfo.SHOW_ONLINE.equals(pi.getShow())) {
            if (BSMainFrame.STATUS_BUSY_STR.equals(pi.getStatus()))
                return busyIcon;
            else if (BSMainFrame.STATUS_ELSE_STR.equals(pi.getStatus()))
                return elseIcon;
            else
                return onlineIcon;
        }

        else if (BSPresenceInfo.SHOW_CHAT.equals(pi.getShow()))
            return chatIcon;
        else if (BSPresenceInfo.SHOW_AWAY.equals(pi.getShow()))
            return awayIcon;
        else if (BSPresenceInfo.SHOW_XA.equals(pi.getShow()))
            return xaIcon;
        else if (BSPresenceInfo.SHOW_DND.equals(pi.getShow()))
            return dndIcon;
        else
            return lurkerIcon;
    }

    /** Constructor */
    public BSJIDLabel(JID jid, String nick, Icon img) {
        super(img);
        this.jid = jid;
        this.nick = nick;
        setToolTipText(nick + " (" + jid.toString() + ")");
    }

    /** Sets current icon */
    public void setImg(Icon img) {
        setIcon(img);
    }

    /** Sets nick */
    public void setNick(String nick) {
        this.nick = nick;
        setToolTipText(nick + " (" + jid.toString() + ")");
    }

    /** Returns label's jid */
    public JID getJID() {
        return jid;
    }

}

⌨️ 快捷键说明

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