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

📄 addfiledialog.java

📁 运用java开发工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package javazip.dialog;

import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javazip.util.*;
import javax.swing.JOptionPane;

public class AddFileDialog extends JDialog {

	private JPanel jContentPane = null;

	private JRadioButton[] jRadioBtnType = new JRadioButton[4];

	private JButton jBtnOK = null;

	private JButton jBtnCancel = null;

	private JTabbedPane jTabbedPaneFormal = null;

	private JPanel jPanelFormal = null;

	private JPanel jPanelEncrypt = null;

	private JPanel jPanelInfo = null;

	private JLabel jLabel = null;

	private JTextField jTextField = null;

	private JButton jButton = null;

	private JPanel jPanel = null;

	private JLabel jLabel1 = null;

	private JComboBox jComboBox = null;

	private JLabel jLabel2 = null;

	private JLabel jLabel3 = null;

	private JComboBox jComboBox1 = null;

	private JLabel jLabel4 = null;

	private JPanel jPanel1 = null;

	private JLabel jLabel5 = null;

	private JPasswordField jPasswordField = null;

	private JLabel jLabel6 = null;

	private JPasswordField jPasswordField1 = null;

	private JCheckBox jCheckBox = null;

	private JLabel jLabel7 = null;

	private JTextArea jTextArea = null;

	private JButton jBtnCommentFile = null;

	private JScrollPane jScrollPane = null;

	private ButtonGroup btg = new ButtonGroup();

	private File list[];

	private File target;

	private Util util = util = new Util();

	public AddFileDialog() throws HeadlessException {
		super();
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Frame arg0) throws HeadlessException {
		super(arg0);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Frame arg0, File list[]) throws HeadlessException {
		super(arg0);
		this.list = list;
		initialize();
	}

	public AddFileDialog(Frame arg0, boolean arg2) throws HeadlessException {
		super(arg0, arg2);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Frame arg0, String arg1, boolean arg2,
			GraphicsConfiguration arg3) {
		super(arg0, arg1, arg2, arg3);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Dialog arg0) throws HeadlessException {
		super(arg0);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Dialog arg0, boolean arg1) throws HeadlessException {
		super(arg0, arg1);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Dialog arg0, String arg1) throws HeadlessException {
		super(arg0, arg1);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Dialog arg0, String arg1, boolean arg2)
			throws HeadlessException {
		super(arg0, arg1, arg2);
		// TODO 自动生成构造函数存根
		initialize();
	}

	public AddFileDialog(Dialog arg0, String arg1, boolean arg2,
			GraphicsConfiguration arg3) throws HeadlessException {
		super(arg0, arg1, arg2, arg3);
		// TODO 自动生成构造函数存根
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(400, 300);
		this.setResizable(false);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension frameSize = this.getSize();
		this.setLocation((screenSize.width - frameSize.width) / 2,
				(screenSize.height - frameSize.height) / 2);
		this.setTitle("压缩文件名和参数");
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();

			jContentPane.setLayout(new FlowLayout());
			jContentPane.add(getJTabbedPaneFormal(), null);
			jContentPane.add(getJBtnOK(), null);
			jContentPane.add(getJBtnCancel(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jRadioButton
	 * 
	 * @return javax.swing.JRadioButton
	 */
	private JRadioButton getJRadioBtnType(int type) {
		btg.add(jRadioBtnType[0]);
		btg.add(jRadioBtnType[1]);
		btg.add(jRadioBtnType[2]);
		btg.add(jRadioBtnType[3]);
		if (jRadioBtnType[0] == null) {
			jRadioBtnType[0] = new JRadioButton();
			jRadioBtnType[0].setText("ZIP");
			jRadioBtnType[0].setSelected(true);
			jRadioBtnType[0]
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							util.curType=util.ZIP;
						}
					});
		}
		if (jRadioBtnType[1] == null) {
			jRadioBtnType[1] = new JRadioButton();
			jRadioBtnType[1].setText("JAR");
			jRadioBtnType[1]
							.addActionListener(new java.awt.event.ActionListener() {
								public void actionPerformed(java.awt.event.ActionEvent e) {
									util.curType=util.JAR;
								}
							});
		}
		if (jRadioBtnType[2] == null) {
			jRadioBtnType[2] = new JRadioButton();
			jRadioBtnType[2].setText("GZ");
			jRadioBtnType[2]
							.addActionListener(new java.awt.event.ActionListener() {
								public void actionPerformed(java.awt.event.ActionEvent e) {
									util.curType=util.GZIP;
								}
							});
		}
		if (jRadioBtnType[3] == null) {
			jRadioBtnType[3] = new JRadioButton();
			jRadioBtnType[3].setText("RAR");
			jRadioBtnType[3]
							.addActionListener(new java.awt.event.ActionListener() {
								public void actionPerformed(java.awt.event.ActionEvent e) {
									util.curType=util.ZIP;
								}
							});
		}
		switch (type) {
		case 1:
			return jRadioBtnType[1];
		case 2:
			return jRadioBtnType[2];
		case 3:
			return jRadioBtnType[3];
		default:
			return jRadioBtnType[0];
		}
	}

	/**
	 * This method initializes jBtnOK
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJBtnOK() {
		if (jBtnOK == null) {
			jBtnOK = new JButton();
			jBtnOK.setText("确定");
			jBtnOK.setPreferredSize(new java.awt.Dimension(60, 25));

			jBtnOK.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if (list.length == 0) {
						JOptionPane.showMessageDialog(null, "请先选择文件!");
						return;
					}
					util.setComment(jTextArea.getText());
					util.compressFile(list, target.toString());
					JOptionPane.showMessageDialog(null, "压缩成功!");
				}
			});
		}
		return jBtnOK;
	}

	/**
	 * This method initializes jBtnCancel
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJBtnCancel() {
		if (jBtnCancel == null) {
			jBtnCancel = new JButton();
			jBtnCancel.setText("取消");
			jBtnCancel.setPreferredSize(new java.awt.Dimension(60, 25));
			jBtnCancel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					dispose();
				}
			});
		}
		return jBtnCancel;
	}

	/**
	 * This method initializes jTabbedPaneFormal
	 * 
	 * @return javax.swing.JTabbedPane
	 */
	private JTabbedPane getJTabbedPaneFormal() {
		if (jTabbedPaneFormal == null) {

⌨️ 快捷键说明

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