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

📄 alertswinmanager.java

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

/*
 * AlertsWinManager.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2003
 *
 *
 * Created on 17 February 2003, 11:09
 */

import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;

/**
 * <code>AlertsWinManager</code> is manager of <code>AlertsDockableWindow</code>s,
 * which supports handling of alerts - displays windows with new messages
 * in different way.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public abstract class AlertsWinManager extends WinManager {
    
    private Vector newMsgWindows = null;
    
    public AlertsWinManager(JTabbedPane tabbedPane) {
        super(tabbedPane);
        newMsgWindows = new Vector();
        
        if (tabbedPane != null)
            tabbedPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent evt) {
                    Object src = evt.getSource();
                    if (src == AlertsWinManager.this.tabbedPane) {
                        Component cmp = AlertsWinManager.this.tabbedPane.getSelectedComponent();
                        if (cmp instanceof AlertsDockableWindow) {
                            updateNewMessageFlags((AlertsDockableWindow)cmp, false);
                        }
                    }
                }
            });
    }
    
    
    /** Updates newMessage flags */
    public void updateNewMessageFlags(AlertsDockableWindow win, boolean newMsg) {
        
        win.setNewMsg(newMsg);
        win.setIcon(getWinImage(win, newMsg));
        
        if (!newMsg) newMsgWindows.remove(win);
        else if (!newMsgWindows.contains(win))
            newMsgWindows.add(win);
        
        // if window is docked
        if (win.isDocked()) {
            int index = tabbedPane.indexOfComponent(win);
            // if window is selected
            if (!newMsg && index != -1) {
                tabbedPane.setForegroundAt(index, null);
                tabbedPane.setIconAt(index, new ImageIcon(getWinImage(win, false)));
            }
            // else window is not selected
            else {
                if (newMsg && index != -1) {
                    tabbedPane.setForegroundAt(index, new Color(255,0,0));
                    tabbedPane.setIconAt(index, new ImageIcon(getWinImage(win, true)));
                }
            }
        }
    }
    
    
    /** Returns if there are some new unread messages */
    public boolean isNewMessage() {
        return !newMsgWindows.isEmpty();
    }
    
    
    /** Closes all chat windows */
    public void closeAllWindows() {
        super.closeAllWindows();
        newMsgWindows.clear();
    }
    
    
    /** Returns <code>Image</code> which should be used for given window
     * when <code>newMsg</code> status.
     */
    abstract protected Image getWinImage(AlertsDockableWindow win, boolean newMsg);
    
}
    

⌨️ 快捷键说明

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