package ;
import ;
import .*;
import ;
import ;
public class CommonComponent extends JFrame {
private JPanel jPanel1, jPanel2, jPanel3;
private JButton jButton1, jButton2, jButton3;
private JScrollPane scroll;
private JLabel name1, name2;
private JTextField field1, field2;
public static JTextArea jTextArea;
private static CommonComponent frame;
public CommonComponent() {
//初始化四个panel对象
jPanel1 = new JPanel();
jPanel2 = new JPanel();
jPanel3 = new JPanel();
this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
// 标签
name1 = new JLabel("encrypt-rule:");
// 文本域
field1 = new JTextField(30);
//按钮
jButton1 = new JButton("选择路径");
(name1);
(field1);
(jButton1);
this.add(jPanel1);
// 标签
name2 = new JLabel("decrypt-rule:");
// 文本域
field2 = new JTextField(30);
//按钮
jButton2 = new JButton("选择路径");
(name2);
(field2);
(jButton2);
this.add(jPanel2);
//按钮
jButton3 = new JButton("开始解密");
(jButton3);
this.add(jPanel3);
//下方显示信息
jTextArea = new JTextArea(1, 1);
//把定义的JTextArea放到JScrollPane里面去
scroll = new JScrollPane(jTextArea);
//分别设置水平和垂直滚动条自动出现
(
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
(true);
this.add(scroll);
init();
}
public void init() {
//选择加密规则路径
(new ActionListener() {
public void actionPerformed(ActionEvent e) {
chooiceDirPath(field1);
}
});
//选择解密路径
(new ActionListener() {
public void actionPerformed(ActionEvent e) {
chooiceDirPath(field2);
}
});
(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String encrytPath = ();
String decrytPath = ();
//开启一个子线程提高执行效率
new Thread(){
public void run() {
FortifyRuleDecrypter fortifyRuleDecrypter = new FortifyRuleDecrypter(encrytPath, decrytPath);
();
}
}.start();
}
});
}
public void chooiceDirPath(JTextField field) {
JFileChooser fileChooser = new JFileChooser("D:\\");
(JFileChooser.DIRECTORIES_ONLY);
int returnVal = (fileChooser);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String filePath = ().getAbsolutePath();
(filePath);
}
}
/* public void outputUI() {//捕获控制台输出到GUI界面上
OutputStream textAreaStream = new OutputStream() {
public void write(int b) throws IOException {
(((char) b));
}
public void write(byte b[]) throws IOException {
(new String(b));
}
public void write(byte b[], int off, int len) throws IOException {
(new String(b, off, len));
}
};
PrintStream myOut = new PrintStream(textAreaStream);
(myOut);
(myOut);
}
*/
public static void main(String[] args) {
frame = new CommonComponent();
("规则解密");
(800, 600);
(null);
(JFrame.EXIT_ON_CLOSE);
// 自适应
// ();
(true);
}
}