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

📄 bscomposemsgwin.java

📁 一款即时通讯软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package edu.ou.kmi.buddyspace.gui;

/*
 * BSComposeMsgWin.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2002
 *
 *
 * Created on 14 November 2002, 12:16
 */

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

import org.jabber.jabberbeans.*;
import org.jabber.jabberbeans.util.*;
import org.jabber.jabberbeans.Extension.*;

import edu.ou.kmi.buddyspace.core.*;
import edu.ou.kmi.buddyspace.utils.*;

/**
 * Window for composing plain messages.
 * Uses <code>BSMsgWinManager</code> to send messages.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class BSComposeMsgWin extends DockableWindow 
                             implements ActionListener {
                              
    private JPanel mainPanel;
    protected Frame mainFrame;
    
    private JScrollPane msgScrollPane;
    protected JTextArea msgTextArea;
    protected JButton closeButton;
    protected JButton sendButton;
    private JPanel buttonPanel;
    protected JButton dockButton;
    private JPanel checkBoxesPanel;
    protected JList recipientList;
    private JScrollPane recipientScrollPane;
    //private JComboBox recipientComboBox;
    //private JComboBox groupComboBox;
    protected JButton addJIDButton;
    protected JButton addOnlineJIDButton;
    protected JButton addGroupButton;
    private JButton removeJIDsButton;
    protected JTextField subjectTextField;
    
    /*private BSChooseJIDDialog addJIDDialog;
    private BSChooseGroupDialog addGroupDialog;*/
    
    private TreeMap rosterJids;
    private TreeMap recipientJids;
    private BSRosterBean rosterBean;
    private BSPresenceBean presenceBean;
    
    /** Constructor */
    BSComposeMsgWin(Frame parent, BSMsgWinManager winMan, String ID, String title,
                 Image icon, BSRosterBean rosterBean, boolean docked) {
                    
        this(parent, winMan.mainFrame, winMan, ID, title, icon, rosterBean, docked);
    }
    
    /** Constructor */
    public BSComposeMsgWin(Frame parent, BSMainFrame mainFrame, WinManager winMan, 
                           String ID, String title, Image icon, 
                           BSRosterBean rosterBean, boolean docked) {
                    
        this(parent, mainFrame, winMan, ID, title, icon, rosterBean, null, docked);
    }
    
    /** Constructor */
    BSComposeMsgWin(Frame parent, BSMsgWinManager winMan, String ID, String title,
                 Image icon, BSRosterBean rosterBean, BSPresenceBean presenceBean, boolean docked) {
                    
        this(parent, winMan.mainFrame, winMan, ID, title, icon, rosterBean, presenceBean, docked);
    }
    
    /** Constructor */
    public BSComposeMsgWin(Frame parent, BSMainFrame mainFrame, WinManager winMan, 
                           String ID, String title, Image icon, 
                           BSRosterBean rosterBean, BSPresenceBean presenceBean,
                           boolean docked) {
                    
        super(ID, title, icon, docked, winMan);
        
        this.mainFrame = mainFrame;
        rosterJids = new TreeMap();
        recipientJids = new TreeMap();
        this.rosterBean = rosterBean;
        this.presenceBean = presenceBean;
        
        initComponents();
        //initAddDialogs();
    }
    
    /** Inits components */
    private void initComponents() {
        GridBagConstraints gridBagConstraints;
        
        mainPanel = new JPanel(new BorderLayout());
        
        msgScrollPane = new JScrollPane();
        msgScrollPane.setAutoscrolls(true);
        msgTextArea = new JTextArea();
        msgTextArea.setEditable(true);
        msgTextArea.setLineWrap(true);
        msgTextArea.setWrapStyleWord(true);
        msgScrollPane.setViewportView(msgTextArea);
        //msgTextArea.addKeyListener(this);
        
        JPanel buttonPanel = new JPanel();
        closeButton = new JButton("Close");
        closeButton.addActionListener(this);
        sendButton = new JButton("Send");
        sendButton.addActionListener(this);
        buttonPanel.add(sendButton);
        buttonPanel.add(closeButton);
        
        JPanel checkBoxesPanel = new JPanel();
        Icon icon = new ImageIcon(ClassLoader.getSystemResource(!docked?
                                "images/dock.gif" : "images/float.gif"));
        dockButton = new JButton(icon);
        dockButton.setToolTipText(docked? "Float" : "Dock");
        dockButton.addActionListener(this);
        checkBoxesPanel.add(dockButton);
        if (!OSVersion.isJava1Point4orHigher())
            dockButton.setEnabled(false);
        
        JPanel headerPanel = new JPanel(new GridBagLayout());
        
        JLabel recipientLabel = new JLabel("Recipients:");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        headerPanel.add(recipientLabel, gridBagConstraints);
        
        recipientList = new JList(new DefaultListModel());
        recipientList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        //recipientList.setPreferredSize(new Dimension(10, 10));
        recipientScrollPane = new JScrollPane(recipientList);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.weightx = 1;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        headerPanel.add(recipientScrollPane, gridBagConstraints);
        
        /*recipientComboBox = new JComboBox();
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        headerPanel.add(recipientComboBox, gridBagConstraints);*/
        
        addJIDButton = new JButton("Add JID");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        addJIDButton.addActionListener(this);
        headerPanel.add(addJIDButton, gridBagConstraints);
        
        addOnlineJIDButton = new JButton("Add online JID");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        addOnlineJIDButton.addActionListener(this);
        headerPanel.add(addOnlineJIDButton, gridBagConstraints);
        
        /*groupComboBox = new JComboBox();
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        headerPanel.add(groupComboBox, gridBagConstraints);*/
        
        addGroupButton = new JButton("Add group");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        addGroupButton.addActionListener(this);
        headerPanel.add(addGroupButton, gridBagConstraints);
        
        removeJIDsButton = new JButton("Remove");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        removeJIDsButton.addActionListener(this);
        headerPanel.add(removeJIDsButton, gridBagConstraints);
        
        JLabel subjectLabel = new JLabel("Subject: ");
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;

⌨️ 快捷键说明

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