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

📄 registrypanel.java

📁 JavaExplorer是一个独立于平台的浏览器
💻 JAVA
字号:
/**  * File and FTP Explorer  * Copyright 2002  * BOESCH Vincent  *  * 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.dialog;import java.awt.*;import java.awt.event.*;import javaexplorer.Launcher;import javaexplorer.util.registry.Registry;import javax.swing.*;import javax.swing.border.*;import javax.swing.table.*;/** *@author     BOESCH Vincent *@created    21 janvier 2002 *@version    3.3 * * 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. * */public class RegistryPanel extends JPanel implements ActionListener {    private Launcher _launcher = null;    private Registry _registry = null;    BorderLayout borderLayout1 = new BorderLayout();    BorderLayout borderLayout2 = new BorderLayout();    GridLayout gridLayout1 = new GridLayout();    GridLayout gridLayout2 = new GridLayout();    JLabel jLabel1 = new JLabel();    JPanel jPanel1 = new JPanel();    JPanel jPanel2 = new JPanel();    JPanel jPanel3 = new JPanel();    JTextField jTextField1 = new JTextField();    JTextField jTextField2 = new JTextField();    JButton jbtAdd = new JButton();    JButton jbtDefine = new JButton();    JButton jbtDelete = new JButton();    JTable jtbRegistry = new JTable();    TitledBorder titledBorder1;    JScrollPane jspRegistry = new JScrollPane(jtbRegistry);    /**     *  Constructeur objet RegistryPanel     *     *@param  launcher  Description of the     *      Parameter     */    public RegistryPanel(Launcher launcher) {        _launcher = launcher;        try {            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 == jbtDefine) {            String loader = openDialog("Open With...");            if (loader != null) {                jTextField2.setText(loader);            }            return;        }        if (obj == jbtAdd) {            addEntry();            return;        }        if (obj == jbtDelete) {            removeEntry();        }    }    /**     *  Adds a feature to the Entry attribute     *  of the RegistryPanel object     */    public void addEntry() {        String ext = jTextField1.getText();        String load = jTextField2.getText();        _registry.addEntry(ext, load);        initRegistry();    }    /**     *  Gets the workingRegistry attribute     *  of the RegistryPanel object     *     *@return    The workingRegistry value     */    public Registry getWorkingRegistry() {        return _registry;    }    /**     */    public void initRegistry() {        String[][] tb = _registry.getTable();        DefaultTableModel dtm = new DefaultTableModel(tb,                new String[] { "Extension", "Loader" });        jtbRegistry.setModel(dtm);    }    /**     *@throws  Exception  Description of the     *      Exception     */    private void jbInit() throws Exception {        titledBorder1 = new TitledBorder("");        this.setLayout(borderLayout1);        this.setBorder(titledBorder1);        borderLayout1.setVgap(5);        gridLayout1.setColumns(4);        jPanel1.setLayout(gridLayout1);        jbtDefine.setText("Define");        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);        jLabel1.setText("opens with");        jPanel2.setLayout(borderLayout2);        jPanel3.setLayout(gridLayout2);        gridLayout2.setColumns(2);        gridLayout2.setHgap(20);        gridLayout2.setVgap(20);        jbtDelete.setText("Remove");        jbtAdd.setText("Add");        this.add(jspRegistry, BorderLayout.CENTER);        this.add(jPanel2, BorderLayout.SOUTH);        jPanel2.add(jPanel1, BorderLayout.CENTER);        jPanel1.add(jTextField1, null);        jPanel1.add(jLabel1, null);        jPanel1.add(jTextField2, null);        jPanel1.add(jbtDefine, null);        jPanel2.add(jPanel3, BorderLayout.SOUTH);        jPanel3.add(jbtDelete, null);        jPanel3.add(jbtAdd, null);        jbtDelete.addActionListener(this);        jbtAdd.addActionListener(this);        jbtDefine.addActionListener(this);        jtbRegistry.setColumnSelectionAllowed(false);        jtbRegistry.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        _registry = Registry.getRegistryCopy();    }    /**     *@param  title  Description of the Parameter     *@return        Description of the Return     *      Value     */    public String openDialog(String title) {        JFileChooser jfc = new JFileChooser();        jfc.setDialogTitle(title);        if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {            return jfc.getSelectedFile().getAbsolutePath();        } else {            return null;        }    }    /**     */    public void removeEntry() {        int reg = jtbRegistry.getSelectedRow();        if (reg >= 0) {            String ext = (String) jtbRegistry.getModel().getValueAt(reg, 0);            if (ext != null) {                _registry.removeEntry(ext);            }            initRegistry();        }    }    /**     *  Sets the launcher attribute of the     *  RegistryPanel object     *     *@param  launcher  The new launcher value     */    public void setLauncher(Launcher launcher) {        _launcher = launcher;    }}

⌨️ 快捷键说明

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