package com.demo;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class ShowFrame extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private String filePath = null;
private JTextField txtPath = null;
private JTextArea textArea = null;
private JTextField txtPsw = null;
public ShowFrame() {
int width = 800;
int height = 600;
this.setTitle("签名查看工具");
this.setSize(width,height);
int srnWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
int srnHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((srnWidth - width) / 2,(srnHeight - height) / 2);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.addWindowListener(new WindowAdapter(){
@Override
public void windowClosed(WindowEvent arg0) {
//System.out.println("windowClosed");
super.windowClosed(arg0);
}
@Override
public void windowClosing(WindowEvent arg0) {
//System.out.println("windowClosing");
super.windowClosing(arg0);
ShowFrame.this.dispose();
System.exit(0);
}
@Override
public void windowOpened(WindowEvent arg0) {
//System.out.println("windowOpened");
super.windowOpened(arg0);
}
});
this.setResizable(false);
textArea = new JTextArea();
textArea.setBackground(new Color(0xff,0xff,0xff));
JPanel pnl = new JPanel();
pnl.setBackground(new Color(0xff,0xff,0xDD));
pnl.setLayout(new GridLayout(1,1));
this.add(pnl,BorderLayout.CENTER);
pnl.add(textArea);
this.add(pnl);
JPanel pn2 = new JPanel();
pn2.setLayout(new GridLayout(1,6));
this.add(pn2,BorderLayout.SOUTH);
JLabel lblHint = new JLabel("签名文件路径:");
txtPath = new JTextField();
//txtPath.setEditable(false);
JLabel lblPsw = new JLabel("签名密码:");
txtPsw = new JTextField();
JButton btnLoad = new JButton("加载...");
JButton btnShow = new JButton("查看");
pn2.add(lblHint);
pn2.add(txtPath);
pn2.add(lblPsw);
pn2.add(txtPsw);
pn2.add(btnLoad);
pn2.add(btnShow);
this.setVisible(true);
btnLoad.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
//System.out.println("load...");
openFile();
}
});
btnShow.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
//System.out.println("btnShow...");
doShow();
}
});
}
private void openFile() {
textArea.removeAll();
txtPath.setText("");
filePath = null;
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
jfc.showDialog(new JLabel(), "选择");
File file = jfc.getSelectedFile();
if (file != null || file.isFile()) {
filePath = file.getAbsolutePath();
txtPath.setText(filePath);
} else {
txtPath.setText("文件错误");
}
//System.out.println(jfc.getSelectedFile().getName());
}
private void doShow() {
if (filePath == null) {
JOptionPane.showMessageDialog(null, "请选择要查看的签名文件","提示",JOptionPane.WARNING_MESSAGE);
return ;
}
String psw = txtPsw.getText();
if (psw == null || psw.trim().length() == 0) {
JOptionPane.showMessageDialog(null, "输入签名密码","提示",JOptionPane.WARNING_MESSAGE);
return ;
}
textArea.removeAll();
KeystoreUtils.show(filePath, psw,textArea);
}
}
android 签名查看工具
5星 · 超过95%的资源 需积分: 0 26 浏览量
更新于2015-08-31
收藏 17KB RAR 举报
签名查看工具:
1.在各个开发者平台上发布作用时,基本都需要应用的签名值,
MD5或SHA1值,用命令行查看时,多了很多无的用的字符如:“:”
此工具,指定一个文件和签名密码真接返回优化后的值
2.实现流程可参考源码项目