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

📄 jxfileinfoframe.java

📁 JavaExplorer是一个独立于平台的浏览器
💻 JAVA
字号:
/**  * File and FTP Explorer  * Copyright 2002  *  * 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 2  * of the License, 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  */package javaexplorer.gui.internal;import java.awt.*;import java.awt.event.*;import javaexplorer.model.XFile;import javaexplorer.ressource.*;import javaexplorer.util.ExplorerUtil;import javax.swing.*;import javax.swing.border.*;/** *@author     BOESCH Vincent *@created    21 janvier 2002 *@version    3.3 */public class JXFileInfoFrame extends JInternalFrame implements ActionListener,    Runnable {    private XFile[] _tb_xf = null;    private BorderLayout borderLayout1 = new BorderLayout();    private GridLayout gridLayout1 = new GridLayout();    private JPanel jPanel1 = new JPanel();    private JPanel jPanel2 = new JPanel();    private JButton jbtOk = new JButton();    private JLabel jlbDirs = new JLabel();    private JLabel jlbFiles = new JLabel();    private JLabel jlbName = new JLabel();    private JLabel jlbSize = new JLabel();    private JPanel jpnlInfo = new JPanel();    private JLabel lblDirs = new JLabel();    private JLabel lblFiles = new JLabel();    private JLabel lblName = new JLabel();    private JLabel lblSize = new JLabel();    private boolean stopped = false;    Thread tSize = null;    private TitledBorder titledBorder1;    private TitledBorder titledBorder2;    private TitledBorder titledBorder3;    private TitledBorder titledBorder4;    private TitledBorder titledBorder5;    private long totalDirs = 0;    private long totalFiles = 0;    private long totalLength = 0;    /**     *  Constructeur objet JXFileInfoFrame     *     *@param  tb_xf  Description of the Parameter     */    public JXFileInfoFrame(XFile[] tb_xf) {        super("Info", false, true, false, false);        try {            _tb_xf = tb_xf;            jbInit();        } catch (Exception e) {            javaexplorer.util.Log.addError(e);        }    }    /**     *@param  e  Description of the Parameter     */    public void actionPerformed(ActionEvent e) {        Object obj = e.getSource();        if (obj == jbtOk) {            stopped = true;            if (tSize != null) {                try {                    tSize.join();                } catch (Exception ex) {                }            }            this.setVisible(false);            try {                this.setClosed(true);            } catch (Exception ex2) {            }        }    }    /**     *  Adds a feature to the Recursive attribute     *  of the JXFileInfoFrame object     *     *@param  f  The feature to be added to     *      the Recursive attribute     */    private void addRecursive(XFile f) {        if (stopped) {            return;        }        if (f.isDirectory()) {            totalDirs++;            jlbDirs.setText("" + totalDirs);            XFile[] tb_file = f.listXFiles();            if (tb_file != null) {                for (int i = 0; i < tb_file.length; i++) {                    addRecursive(tb_file[i]);                }            }        } else {            totalFiles++;            jlbFiles.setText("" + totalFiles);            totalLength += f.length();            jlbSize.setText(ExplorerUtil.getLengthAsString(totalLength));        }    }    /**     *@throws  Exception  Description of the     *      Exception     */    private void jbInit() throws Exception {        titledBorder2 = new TitledBorder("");        titledBorder3 = new TitledBorder("");        titledBorder4 = new TitledBorder("");        titledBorder5 = new TitledBorder("");        jbtOk.addActionListener(this);        jbtOk.setText("OK");        jbtOk.setToolTipText("");        this.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);        this.setTitle("Info");        this.setBorder(BorderFactory.createEtchedBorder());        titledBorder1 = new TitledBorder("");        jpnlInfo.setLayout(borderLayout1);        jpnlInfo.setBackground(SystemColor.info);        jpnlInfo.setBorder(titledBorder5);        this.getContentPane().setLayout(new BorderLayout());        jPanel2.setLayout(gridLayout1);        gridLayout1.setRows(4);        gridLayout1.setColumns(2);        gridLayout1.setVgap(4);        lblName.setText("Name");        lblSize.setText("Size");        jPanel1.setBackground(SystemColor.info);        jPanel2.setBackground(SystemColor.info);        lblFiles.setText("Files");        lblDirs.setText("Dirs");        this.getContentPane().add(jpnlInfo, BorderLayout.CENTER);        jpnlInfo.add(jPanel1, BorderLayout.SOUTH);        jPanel1.add(jbtOk, null);        jpnlInfo.add(jPanel2, BorderLayout.CENTER);        jPanel2.add(lblName, null);        jPanel2.add(jlbName, null);        jPanel2.add(lblSize, null);        jPanel2.add(jlbSize, null);        jPanel2.add(lblDirs, null);        jPanel2.add(jlbDirs, null);        jPanel2.add(lblFiles, null);        jPanel2.add(jlbFiles, null);        if (ImageRessource.iiInfo != null) {            this.setFrameIcon(ImageRessource.iiInfo);        }        setBounds(10, 10, 350, 150);        setOpaque(true);        setBackground(Color.white);        tSize = new Thread(this);        tSize.start();    }    /**     *  Main processing method for the JXFileInfoFrame     *  object     */    public void run() {        setTitle("Info (processing)");        if (_tb_xf == null) {            return;        }        if (_tb_xf.length == 1) {            jlbName.setText(_tb_xf[0].toString());        } else {            jlbName.setText(TextRessource.MAINFRAME_GLOBAL_SELECTION);        }        for (int i = 0; i < _tb_xf.length; i++) {            addRecursive(_tb_xf[i]);        }        tSize = null;        setTitle("Info");    }}

⌨️ 快捷键说明

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