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

📄 conversationpanel.java

📁 JBother是纯Java开发的Jabber(即时消息开源软件)客户端。支持群组聊天
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  Copyright (C) 2003 Adam Olsen *  This program 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 1, or (at your option) *  any later version. *  This program 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 this program; if not, write to the Free Software *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */package com.valhalla.jbother;import java.awt.Font;import java.awt.event.*;import java.io.File;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.Locale;import java.util.ResourceBundle;import java.util.TimeZone;import javax.swing.*;import com.valhalla.gui.*;import com.valhalla.jbother.jabber.BuddyStatus;import com.valhalla.jbother.plugins.events.MessageReceivedEvent;import com.valhalla.settings.Settings;import net.infonode.tabbedpanel.*;import net.infonode.tabbedpanel.titledtab.*;import net.infonode.util.*;import org.jivesoftware.smack.packet.*;/** * Provides common tools for conversation windows (such as logging). Must be * extended. * * @author Adam Olsen * @author Yury Soldak (tail) * @author Andrey Zakirov * @created April 10, 2005 * @version 1.1 * @see com.valhalla.jbother.jabber.BuddyStatus */public abstract class ConversationPanel extends JPanel implements        LogViewerCaller, TabFramePanel {    private ResourceBundle resources = ResourceBundle.getBundle(            "JBotherBundle", Locale.getDefault());    protected BuddyStatus buddy;    private TitledTab tab;    protected Message lastReceived = null;    MJTextArea textEntryArea = new MJTextArea(true);    public void ConversationPanel(BuddyStatus buddy) {this.buddy = buddy;}    /**     * the conversation area     */    protected ConversationArea conversationArea = new ConversationArea();    private int oldMaximum = 0;    /**     * the close timer     */    protected javax.swing.Timer timer = new javax.swing.Timer(600000,            new CloseListener());    public JFrame getFrame() { return frame; }    /**     * the containing frame     */    protected JFrame frame = null;    /**     * if the listeners have been added     */    protected boolean listenersAdded = false;    public void setTab( TitledTab tab ) { this.tab = tab; }    public TitledTab getTab() { return tab; }    /**     * Sets up the defaults in the ConversationPanel     *     * @param buddy     *            the buddy that this window corresponds to     */    public ConversationPanel(BuddyStatus buddy) {        this.buddy = buddy;        startLog();    }    /**     * Listens for a right click - and displays a menu if it's caught     *     * @author Adam Olsen     * @created October 26, 2004     * @version 1.0     */    class RightClickListener extends MouseAdapter {        private JPopupMenu menu;        private JMenuItem item = new JMenuItem(resources                .getString("closeConversation"));        private boolean containsCloseItem = false;        /**         * Constructor for the RightClickListener object         *         * @param menu         *            the menu         */        public RightClickListener(JPopupMenu menu) {            this.menu = menu;        }        /**         * Description of the Method         *         * @param e         *            the event         */        public void mousePressed(MouseEvent e) {            checkPop(e);        }        /**         * @param e         *            the mouse event         */        public void mouseReleased(MouseEvent e) {            checkPop(e);        }        /**         * @param e         *            the mouse event         */        public void mouseClicked(MouseEvent e) {            checkPop(e);        }        /**         * @param e         *            the mouse event         */        public void checkPop(MouseEvent e) {            if (e.isPopupTrigger()) {                if (conversationArea.getSelectedText() != null)                    return;                if (Settings.getInstance().getBoolean("useTabbedWindow")                        && !containsCloseItem) {                    containsCloseItem = true;                    menu.add(item);                    item.addActionListener(new ActionListener() {                        public void actionPerformed(ActionEvent e) {                            checkCloseHandler();                        }                    });                } else if (!Settings.getInstance()                        .getBoolean("useTabbedWindow")                        && containsCloseItem) {                    containsCloseItem = false;                    menu.remove(item);                }                // if a right click is detected, show the popup menu                menu.show(e.getComponent(), e.getX(), e.getY());            }        }    }    /**     * @return true if the TabFrame panel listeners have already been added to     *         this panel     */    public boolean listenersAdded() {        return listenersAdded;    }    /**     * Sets whether or not the TabFrame panel listeners have been added     *     * @param added     *            true if they have been added     */    public void setListenersAdded(boolean added) {        this.listenersAdded = added;    }    /**     * @return the input area of this panel     */    public JComponent getInputComponent() {        return conversationArea;    }    /**     * @return the name of the tab in the TabFrame     */    public String getPanelName() {        if (buddy != null) {            String n = buddy.getName();            if (n == null)                n = buddy.getUser();            int i = n.indexOf("@");            if (i > -1)                n = n.substring(0, i);            return n;        } else {            return "blank";        }    }    /**     * @return the title of the window in the TabFrame     */    public String getWindowTitle() {        if (buddy != null) {            if( buddy.getName() == null )            {                return buddy.getUser();            }            if ((buddy.getName().toLowerCase ()).matches(buddy.getUser()))            {                return buddy.getName();            }            else            {                return buddy.getName() +  " (" + buddy.getUser() + ")";            }        }        else {            return "Blank Message";        }    }    /**     * @return the tooltip for this tab in the TabFrame     */    public String getTooltip() {        if (buddy != null) {            return buddy.getUser();        } else {            return "Blank Message";        }    }    /**     * @return the containing frame for this panel     */    public JFrame getContainingFrame() {        return frame;    }    /**     * @param frame     *            the new containing frame     */    public void setContainingFrame(JFrame frame) {        this.frame = frame;    }

⌨️ 快捷键说明

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