📄 desjiajiemi.txt
字号:
public void jButtonCryDest_mouseClicked(MouseEvent mouseEvent) {
JFrame fileChooseFrame = new JFrame("选择加密后的文件");
JFileChooser jFileChooserKeyFile = new JFileChooser();
jFileChooserKeyFile.setDialogTitle("选择加密后的文件");
int result = jFileChooserKeyFile.showOpenDialog(fileChooseFrame);
File selectedFile = jFileChooserKeyFile.getSelectedFile();
if (selectedFile != null) {
this.jTextFieldCryDest.setText(selectedFile.getPath());
}
}
// 加密文件处理
public void jButtonCryFile_mouseClicked(MouseEvent mouseEvent) {
String cryKeyLoc = this.jTextFieldCryKey.getText();
String crySrcLoc = this.jTextFieldCrySrc.getText();
String cryDestLoc = this.jTextFieldCryDest.getText();
if (cryKeyLoc == null || "".equals(cryKeyLoc)) {
JOptionPane.showMessageDialog(this, "请选择key文件!");
return;
}
if (crySrcLoc == null || "".equals(crySrcLoc)) {
JOptionPane.showMessageDialog(this, "请选择要加密的文件!");
return;
}
if (cryDestLoc == null || "".equals(cryDestLoc)) {
JOptionPane.showMessageDialog(this, "请选择加密后的文件!");
return;
}
File keyFile = new File(cryKeyLoc);
File srcFile = new File(crySrcLoc);
File destFile = new File(cryDestLoc);
ProcessFrame proFrame = new ProcessFrame(this);
proFrame.setTitle("正在加密文件 "+srcFile.getPath());
proFrame.jLabel1.setText("应用key文件:"+keyFile.getPath());
proFrame.jLabel2.setText("加密文件:"+srcFile.getPath());
proFrame.jLabel3.setText("加密后文件:"+destFile.getPath());
proFrame.jLabel4.setText("删除原文件:"+(this.jCheckBoxDelSrc.isSelected()?"是":"否"));
proFrame.jLabel5.setText("完成字节:0");
proFrame.jLabel6.setText("总共字节:"+String.valueOf(srcFile.length()));
proFrame.jButton1.setText("取消");
proFrame.jButton2.setText("暂停");
// proFrame.jLabel7.setText("0%");
proFrame.setVisible(true);
proFrame.show();
proFrame.jProgressBar1.setMaximum((int)srcFile.length());
proFrame.jProgressBar1.setMinimum(0);
proFrame.jProgressBar1.setValue(0);
// 记动加密线程
CryptoDESFileThread thread = new CryptoDESFileThread(proFrame,keyFile,srcFile,destFile);
proFrame.desFileThread = thread;
thread.start();
}
// 解密文件 ,选择 key 文件
public void jButtonDeCryKey_mouseClicked(MouseEvent mouseEvent) {
JFrame fileChooseFrame = new JFrame("选择key文件");
JFileChooser jFileChooserKeyFile = new JFileChooser();
jFileChooserKeyFile.setDialogTitle("选择key文件");
int result = jFileChooserKeyFile.showOpenDialog(fileChooseFrame);
File selectedFile = jFileChooserKeyFile.getSelectedFile();
if (selectedFile != null) {
this.jTextFieldDeCryKey.setText(selectedFile.getPath());
}
}
// 文件解密,选择 源文件
public void jButtonDeCrySrc_mouseClicked(MouseEvent mouseEvent) {
JFrame fileChooseFrame = new JFrame("选择需要解密的文件");
JFileChooser jFileChooserKeyFile = new JFileChooser();
jFileChooserKeyFile.setDialogTitle("选择需要解密的文件");
int result = jFileChooserKeyFile.showOpenDialog(fileChooseFrame);
File selectedFile = jFileChooserKeyFile.getSelectedFile();
if (selectedFile != null) {
this.jTextFieldDeCrySrc.setText(selectedFile.getPath());
String s = selectedFile.getPath();
this.jTextFieldDeCryDest.setText(s.substring(0,s.lastIndexOf(".")));
}
}
// 文件解密, 选择目标文件
public void jButtonDeCryDest_mouseClicked(MouseEvent mouseEvent) {
JFrame fileChooseFrame = new JFrame("选择解密后的文件");
JFileChooser jFileChooserKeyFile = new JFileChooser();
jFileChooserKeyFile.setDialogTitle("选择解密后的文件");
int result = jFileChooserKeyFile.showOpenDialog(fileChooseFrame);
File selectedFile = jFileChooserKeyFile.getSelectedFile();
if (selectedFile != null) {
this.jTextFieldDeCryDest.setText(selectedFile.getPath());
}
}
// 解密文件处理
public void jButtonDeCryFile_mouseClicked(MouseEvent mouseEvent) {
String cryKeyLoc = this.jTextFieldDeCryKey.getText();
String crySrcLoc = this.jTextFieldDeCrySrc.getText();
String cryDestLoc = this.jTextFieldDeCryDest.getText();
if (cryKeyLoc == null || "".equals(cryKeyLoc)) {
JOptionPane.showMessageDialog(this, "请选择key文件!");
return;
}
if (crySrcLoc == null || "".equals(crySrcLoc)) {
JOptionPane.showMessageDialog(this, "请选择要解密的文件!");
return;
}
if (cryDestLoc == null || "".equals(cryDestLoc)) {
JOptionPane.showMessageDialog(this, "请选择解密后的文件!");
return;
}
File keyFile = new File(cryKeyLoc);
File srcFile = new File(crySrcLoc);
File destFile = new File(cryDestLoc);
ProcessFrame proFrame = new ProcessFrame(this);
proFrame.setTitle("正在解密文件 "+srcFile.getPath());
proFrame.jLabel1.setText("应用key文件:"+keyFile.getPath());
proFrame.jLabel2.setText("解密文件:"+srcFile.getPath());
proFrame.jLabel3.setText("解密后文件:"+destFile.getPath());
proFrame.jLabel4.setText("删除原文件:"+(this.jCheckBoxDelSrc.isSelected()?"是":"否"));
proFrame.jLabel5.setText("完成字节:0");
proFrame.jLabel6.setText("总共字节:"+String.valueOf(srcFile.length()));
// proFrame.jLabel7.setText("0%");
proFrame.jButton1.setText("取消");
proFrame.jButton2.setText("暂停");
proFrame.setVisible(true);
proFrame.show();
proFrame.jProgressBar1.setMaximum((int)srcFile.length());
proFrame.jProgressBar1.setMinimum(0);
proFrame.jProgressBar1.setValue(0);
// 启动解密线程
DeCryptoDESFileThread thread = new DeCryptoDESFileThread(proFrame,keyFile,srcFile,destFile);
proFrame.desFileThread = thread;
thread.start();
}
public void jMenuAbout_mouseClicked(MouseEvent mouseEvent) {
JOptionPane.showMessageDialog(this, "文件加密\n作者:廖武锋\n日期:2006-06-18");
}
}
//////////////////////////////////// 文件加密 处理类 BEGIN ///////////////////////////////////////////////////
class CryptFrame_jButtonCryFile_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonCryFile_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonCryFile_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonCryDest_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonCryDest_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonCryDest_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonCrySrc_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonCrySrc_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonCrySrc_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonCryKey_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonCryKey_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonCryKey_mouseClicked(mouseEvent);
}
}
/////////////////////////////////////////////////////// 文件加密处理类 END ////////////////////////////////////////////////////////
/////////////////////////////////////////////////////// 文件解密处理类 BEGIN /////////////////////////////////////////////////////////
class CryptFrame_jButtonDeCryFile_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonDeCryFile_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonDeCryFile_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonDeCryDest_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonDeCryDest_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonDeCryDest_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonDeCrySrc_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonDeCrySrc_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonDeCrySrc_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonDeCryKey_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonDeCryKey_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonDeCryKey_mouseClicked(mouseEvent);
}
}
/////////////////////////////////////////////////////// 文件解密处理类 END //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////// 产生key文件处理类 BEGIN /////////////////////////////////////////////////////////////
class CryptFrame_jButtonGenKeyFile_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonGenKeyFile_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonGenKeyFile_mouseClicked(mouseEvent);
}
}
class CryptFrame_jButtonSelect_mouseAdapter extends MouseAdapter {
private CryptFrame adaptee;
CryptFrame_jButtonSelect_mouseAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent mouseEvent) {
adaptee.jButtonSelect_mouseClicked(mouseEvent);
}
}
/////////////////////////////////////////////////////// 产生key文件处理类 END /////////////////////////////////////////////////////////////
///////////////////////////////////////////// 菜单处理类 BEGIN /////////////////////////////////
class CryptFrame_jMenuFileExit_ActionAdapter implements ActionListener {
CryptFrame adaptee;
CryptFrame_jMenuFileExit_ActionAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jMenuFileExit_actionPerformed(actionEvent);
}
}
class CryptFrame_jMenuFileGenKeyFile_ActionAdapter implements ActionListener {
CryptFrame adaptee;
CryptFrame_jMenuFileGenKeyFile_ActionAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jMenuFileGenKeyFile_actionPerformed(actionEvent);
}
}
class CryptFrame_jMenuFileCryptFile_ActionAdapter implements ActionListener {
CryptFrame adaptee;
CryptFrame_jMenuFileCryptFile_ActionAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jMenuFileCryptFile_actionPerformed(actionEvent);
}
}
class CryptFrame_jMenuFileDeCryptfile_ActionAdapter implements ActionListener {
CryptFrame adaptee;
CryptFrame_jMenuFileDeCryptfile_ActionAdapter(CryptFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jMenuFileDeCryptfile_actionPerformed(actionEvent);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -