package com.qy.ui;

import javax.swing.JFrame;
import javax.swing.JEditorPane;
import javax.swing.JButton;
import javax.swing.JLabel;

import com.qy.utils.AESTools;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class AESUi extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public AESUi() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setTitle("AES\u5DE5\u5177");
		// TODO Auto-generated constructor stub
		initView();
	}
	private JEditorPane output,input;
	private void initView() {
		setSize(807, 493);
		getContentPane().setLayout(null);
		output = new JEditorPane();
		output.setBounds(48, 250, 691, 168);
		getContentPane().add(output);
		
		input = new JEditorPane();
		input.setBounds(48, 38, 691, 144);
		getContentPane().add(input);
		
		JButton button = new JButton("\u52A0\u5BC6");
		button.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String inStr=input.getText();
				String out=new String(AESTools.aesEncrypt(inStr, AESTools.key));
				output.setText(out);
			}
		});
		button.setBounds(499, 195, 113, 27);
		getContentPane().add(button);
		
		JButton button_1 = new JButton("\u89E3\u5BC6");
		button_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String inStr=input.getText();
				String out=AESTools.aesDecrypt(inStr, AESTools.key);
				output.setText(out);
			}
		});
		button_1.setBounds(626, 195, 113, 27);
		getContentPane().add(button_1);
		
		
		
		JLabel label = new JLabel("\u8F93\u5165");
		label.setBounds(48, 13, 72, 18);
		getContentPane().add(label);
		
		JLabel label_1 = new JLabel("\u8F93\u51FA");
		label_1.setBounds(48, 219, 72, 18);
		getContentPane().add(label_1);
		setVisible(true);
	}
}
