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

📄 tabframe.java

📁 网站即时通讯系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     */    private class DividerListener implements PropertyChangeListener {        public void propertyChange(PropertyChangeEvent e) {            Settings.getInstance().setProperty("dockedBuddyListDivLocation",                    e.getOldValue().toString());        }    }    /**     * Marks a tab for a TabFramePanel if it's not already selected     *     * @param panel     *            the panel to mark     */    public int markTab(TabFramePanel panel) {        if( tabPane.getSelectedTab() == null ) return -1;        if (tabPane.getSelectedTab().getContentComponent() != panel) {            Integer i = (Integer) queueCounts.get(panel);            if (i == null)                i = new Integer(1);            int index = tabPane.getTabIndex(panel.getTab());            if (index == -1)                return index;            TitledTab tab = panel.getTab();            tab.setText(panel.getPanelName() + " ("                    + i.intValue() + ")");            queueCounts.put(panel, new Integer(i.intValue() + 1));            return i.intValue();        }        return -1;    }    /**     * Clears the tab message queue count     */    public void clearTab(TabFramePanel panel) {        TitledTab tab = panel.getTab();        if( tab == null ) return;        tab.setText(panel.getPanelName());        queueCounts.remove(panel);        if (panel instanceof ChatRoomPanel) {            ((ChatRoomPanel) panel).resetMessageToMe();        }    }    /**     * Saves the size of the chat frame     */    public void saveStates() {        if (isVisible()) {            Point location = new Point(getLocationOnScreen());            Settings.getInstance().setProperty("tabFrameX",                    new Double(location.getX()).toString());            Settings.getInstance().setProperty("tabFrameY",                    new Double(location.getY()).toString());        } else {            com.valhalla.Logger.debug("TabFrame is not visible");        }        Dimension size = getSize();        Integer width = new Integer((int) size.getWidth());        Integer height = new Integer((int) size.getHeight());        Settings.getInstance().setProperty("chatFrameWidth", width.toString());        Settings.getInstance()                .setProperty("chatFrameHeight", height.toString());    }    /**     * Switches the current tab in the tab frame     */    public void switchTab(TabbedPanel tabPane) {        com.valhalla.Logger.debug("Switching the tab");        int current = tabPane.getTabIndex(tabPane.getSelectedTab());        current++;        if (current >= tabPane.getTabCount())            current = 0;        tabPane.setSelectedTab(tabPane.getTabAt(current));        TabFramePanel panel = (TabFramePanel) tabPane.getTabAt(current).getContentComponent();        if (panel != null)            focusComponent( panel.getInputComponent() );    }    /**     * Loads the saved settings from any previous settings     */    private void setPreferredLocation() {        //load the settings from the settings file        String xString = Settings.getInstance().getProperty("tabFrameX");        String yString = Settings.getInstance().getProperty("tabFrameY");        if (yString == null)            yString = "100";        if (xString == null)            xString = "100";        double x = 100;        double y = 100;        try {            x = Double.parseDouble(xString);            y = Double.parseDouble(yString);        } catch (NumberFormatException e) {            com.valhalla.Logger.logException(e);        }        if (x < -50.0)            x = 100.0;        if (y < -50.0)            y = 100.0;        setLocation((int) x, (int) y);    }    /**     * Adds the various event listeners     *     * @author Adam Olsen     * @version 1.0     */    private void addListeners() {        MenuItemListener listener = new MenuItemListener();        newItem.addActionListener(listener);        leaveItem.addActionListener(listener);    }    public void addFrameListener (BuddyStatus buddy)    {        final BuddyStatus buddy2=buddy;        addWindowFocusListener ( new WindowFocusListener() {            public void windowGainedFocus (WindowEvent e) {                SwingUtilities.invokeLater(new Runnable() {                    public void run() {                        buddy2.sendNotDisplayedID();                    }                });            }            public void windowLostFocus(WindowEvent e) {            }        });    }    /**     * Listens for a menu item to be clicked     *     * @author Adam Olsen     * @version 1.0     */    private class MenuItemListener implements ActionListener {        public void actionPerformed(ActionEvent e) {            if (e.getSource() == newItem)                new GroupChatBookmarks(thisPointer).setVisible(true);            if (e.getSource() == leaveItem)                closeHandler();        }    }    /**     * Updates the font in all the chat conversationareas     *     * @param font     *            the font to update to     */    public void updateStyles(Font font) {        for (int i = 0; i < tabPane.getTabCount(); i++) {            TabFramePanel panel = (TabFramePanel) tabPane.getTabAt(i).getContentComponent();            panel.updateStyle(font);        }    }    /**     * Set the status in all the rooms     *     * @param mode     *            the presence mode     * @param status     *            the status string     */    public void setStatus(Presence.Mode mode, String status) {        for (int i = 0; i < tabPane.getTabCount(); i++) {            TabFramePanel panel = (TabFramePanel) tabPane.getTabAt(i).getContentComponent();            if (panel instanceof ChatRoomPanel) {                ChatRoomPanel window = (ChatRoomPanel) panel;                MultiUserChat chat = window.getChat();                if( chat == null || !chat.isJoined() ) continue;                //set up a packet to be sent to my user in every groupchat                Presence presence = new Presence(Presence.Type.AVAILABLE,                        status, 0, mode);                presence.setTo(window.getRoomName() + '/'                        + window.getNickname());                if (!BuddyList.getInstance().checkConnection()) {                    BuddyList.getInstance().connectionError();                    return;                }                BuddyList.getInstance().getConnection().sendPacket(presence);            }        }    }    /**     * This not only closes the window, but it leaves all the rooms like it     * should     */    public void closeHandler() {        removeTabListeners();        leaveAll();    }    /**     * Since there is no way to check to see if a message is from someone in a     * chat room, we check to see if the message is coming from the same server     * as a chatroom we are in.     *     * @param server     *            the server to check     */    public boolean isRoomOpen(String server) {        for (int i = 0; i < tabPane.getTabCount(); i++) {            TabFramePanel panel = (TabFramePanel) tabPane.getTabAt(i).getContentComponent();            if (panel instanceof ChatRoomPanel) {                ChatRoomPanel window = (ChatRoomPanel) panel;                if (server.toLowerCase().equals(                        window.getRoomName().toLowerCase()))                    return true;            }        }        return false;    }    /**     * If there is a chatroom open in this frame with a server name, this     * returns the ChatRoomPanel that contains it     *     * @param server     *            the name of the room to get the ChatRoomPanel for     * @return the ChatRoomPanel requested, or <tt>null</tt> if it could not     *         be found     */    public ChatRoomPanel getChatPanel(String server) {        for (int i = 0; i < tabPane.getTabCount(); i++) {            TabFramePanel panel = (TabFramePanel) tabPane.getTabAt(i).getContentComponent();            if (panel instanceof ChatRoomPanel) {                ChatRoomPanel window = (ChatRoomPanel) panel;                if (server.toLowerCase().equals(                        window.getRoomName().toLowerCase()))                    return window;            }        }        return null;    }    /**     * This leaves a chatroom and removes the associated ChatRoomPanel from the     * TabPane     *     * @param window     *            the room to leave     */    public void removePanel(TabFramePanel panel) {        tabPane.removeTab(panel.getTab());        tabPane.validate();        if (panel instanceof ChatRoomPanel) {            ((ChatRoomPanel) panel).leave();            panel = null;        }        try {            panel = (TabFramePanel) tabPane.getSelectedTab().getContentComponent();        }        catch( NullPointerException npe ) { panel = null; }        if (panel != null) {            setTitle(panel.getWindowTitle());            TitledTab tab = panel.getTab();            tab.setText(panel.getPanelName());         } else {            setTitle("JBother");        }        BuddyList.getInstance().stopTabFrame();    }    /**     * Sets the subject of a ChatRoomPanel based on a message that was received     * from the GroupChat server with &lt;subject&gt; in it     *     * @param window     *            the window to set the subject for     */    public void setSubject(ChatRoomPanel window) {        if( tabPane.getSelectedTab() == null) return;        if (!(tabPane.getSelectedTab().getContentComponent() instanceof ChatRoomPanel))            return;        if ((ChatRoomPanel) tabPane.getSelectedTab().getContentComponent() == window) {            setTitle(resources.getString("groupChat") + ": "                    + window.getRoomName());            validate();        }    }    /**     * @param panel     *            the panel to check     * @return true if the tab panel is currently displayed in the tab frame     */    public boolean contains(TabFramePanel panel) {

⌨️ 快捷键说明

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