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

📄 filedialog.java

📁 网站即时通讯系统
💻 JAVA
字号:
package com.valhalla.jbother;import javax.swing.*;import java.awt.*;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import com.valhalla.jbother.jabber.smack.*;import com.valhalla.gui.*;/** *  Created by luke on Feb 2, 2005 4:27:37 PM * *@author     synic *@created    May 25, 2005 *//** *  as Dialogs for sending and receiving files will be very similar, this is the *  basic window with 3 areas: To/From field, Date field, Filename field, *  Description field, size field and two buttons: Reject/Cancel & Accept/Send * *@author     synic *@created    May 25, 2005 */public abstract class FileDialog extends JDialog implements ActionListener,        FileTransferProgressListener {    private static String fId = "$Id$";    /**     *  Description of the Field     */    protected StreamInitiation si;    /**     *  Description of the Field     */    protected StreamInitiation.FileDetails fileDetails;    /**     *  Description of the Field     */    protected JButton ayeButton = new JButton();    /**     *  Description of the Field     */    protected JButton nayButton = new JButton();    /**     *  Description of the Field     */    protected JLabel fromToLabel = new JLabel();    /**     *  Description of the Field     */    protected MJTextField fromToTF = new MJTextField();    /**     *  Description of the Field     */    protected MJTextArea descriptionArea = new MJTextArea();    /**     *  Description of the Field     */    protected MJTextField timeTF = new MJTextField();    /**     *  Description of the Field     */    protected MJTextField fileTF = new MJTextField();    /**     *  Description of the Field     */    protected JLabel sizeLabel = new JLabel("Size: ");    /**     *  Description of the Field     */    protected JLabel statusLabel = new JLabel("");    /**     *  Description of the Field     */    protected FileProgressDialog fileProgressDialog;    /**     *  Description of the Field     */    protected static JFileChooser fileChooser;    /**     *  Constructor for the FileDialog object     *     *@param  aSi                    Description of the Parameter     *@exception  HeadlessException  Description of the Exception     */    public FileDialog(StreamInitiation aSi)             throws HeadlessException {        super(BuddyList.getInstance().getContainerFrame());        si = aSi;        fileDetails = si.getFileDetails();        initialize();    }    /**     *  initialize the dialog     */    private void initialize() {        getRootPane().setDefaultButton(ayeButton);        // set up the layout        JPanel topPanel = new JPanel(new GridLayout(3, 1, 5, 5));        JPanel fromToPanel = new JPanel(new BorderLayout(5, 5));        fromToPanel.add(fromToLabel, BorderLayout.WEST);        fromToPanel.add(fromToTF, BorderLayout.CENTER);        JPanel timePanel = new JPanel(new BorderLayout());        timePanel.add(new JLabel("Time: "), BorderLayout.WEST);        timePanel.add(timeTF, BorderLayout.CENTER);        JPanel fromTimeCombinedPanel = new JPanel(new BorderLayout());        fromTimeCombinedPanel.add(fromToPanel, BorderLayout.CENTER);        fromTimeCombinedPanel.add(timePanel, BorderLayout.EAST);        topPanel.add(fromTimeCombinedPanel);        JPanel filePanel = new JPanel(new BorderLayout(10, 10));        filePanel.add(new JLabel("File: "), BorderLayout.WEST);        filePanel.add(fileTF, BorderLayout.CENTER);        topPanel.add(filePanel);        topPanel.add(sizeLabel);        JPanel centerPanel = new JPanel(new BorderLayout(20, 20));        centerPanel.add(new JScrollPane(descriptionArea), BorderLayout.CENTER);        JPanel buttonPanel = new JPanel();        buttonPanel.add(nayButton);        buttonPanel.add(ayeButton);        JPanel bottomPanel = new JPanel(new BorderLayout());        bottomPanel.add(buttonPanel, BorderLayout.EAST);        bottomPanel.add(statusLabel, BorderLayout.WEST);        JPanel panel = new JPanel(new BorderLayout());        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));        panel.add(topPanel, BorderLayout.NORTH);        panel.add(centerPanel, BorderLayout.CENTER);        panel.add(bottomPanel, BorderLayout.SOUTH);        getContentPane().setLayout(new BorderLayout(5, 5));        getContentPane().add(panel);        // set the buttons        ayeButton.setActionCommand("aye");        ayeButton.addActionListener(this);        nayButton.setActionCommand("nay");        nayButton.addActionListener(this);        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);        // add to DialogTracker so that when the connection is lost, it will be closed        DialogTracker.addDialog(this, true, true);        setSize(450, 300);        setEnabled(true);        setFocusable(true);        Standard.cascadePlacement(this);    }    /**     *  Description of the Method     *     *@param  progress  Description of the Parameter     *@param  update    Description of the Parameter     */    public void progressUpdate(int progress, long update) {        setVisible(false);        if (!fileProgressDialog.getDialog().isVisible()) {            fileProgressDialog.getDialog().setVisible(true);        }        if (progress >= 100) {            dispose();            fileProgressDialog.getDialog().dispose();        }    }    /**     *  Description of the Method     *     *@param  e  Description of the Parameter     */    public void actionPerformed(java.awt.event.ActionEvent e) {        if (e.getActionCommand().equals("aye")) {            doAye();        } else if (e.getActionCommand().equals("nay")) {            doNay();        }    }    /**     *  Description of the Method     */    protected void disableAll() {        ayeButton.setEnabled(false);        fromToTF.setEnabled(false);        descriptionArea.setEnabled(false);        timeTF.setEnabled(false);        fileTF.setEnabled(false);    }    /**     *  Gets the fileDetails attribute of the FileDialog object     *     *@return    The fileDetails value     */    public StreamInitiation.FileDetails getFileDetails() {        return fileDetails;    }    /**     *  Sets the fileDetails attribute of the FileDialog object     *     *@param  aFileDetails  The new fileDetails value     */    public void setFileDetails(StreamInitiation.FileDetails aFileDetails) {        fileDetails = aFileDetails;        timeTF.setText(fileDetails.getDate());        fileTF.setText(fileDetails.getFileName());        sizeLabel.setText("Size: " + fileDetails.getFileSize());        descriptionArea.setText(fileDetails.getDescription());    }    /**     *  method called when "Aye" button is pressed to be implemented in child     *  class     */    protected abstract void doAye();    /**     *  method called when "Nay" button is pressed to be implemented in child     *  class     */    protected abstract void doNay();    /**     *  method called to clean up to be implemented in child class     */    protected abstract void cleanUp();}

⌨️ 快捷键说明

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