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

📄 interpreterframe.java

📁 提供图形界面加密
💻 JAVA
字号:
package com.xwtec.Interpreter.GUI;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JLabel;
import javax.swing.JButton;

import java.awt.Container;
import java.awt.event.ActionListener;
import java.awt.Cursor;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.SystemColor;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;

import java.lang.Exception;

import com.xwtec.Interpreter.EncryptMtic.EytMtic;



/**
 * <p>Title: Interpreter</p>
 *
 * <p>Description: Password Interpreter</p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: XW </p>
 *
 * @author Mars.Pylisin
 * @version 1.0
 */
public class InterpreterFrame
        extends JFrame
{
    /**
     * JPanel Set of this frame
     */
    JPanel contentPane = new JPanel();
    JPanel panel_Ipt_Pwd = new JPanel();
    JPanel panel_Cfm_Pwd = new JPanel();
    JPanel panel_Eyt_Msg = new JPanel();
    JPanel panel_button = new JPanel();
    JPanel panel_s = new JPanel();
    JPanel panel_c = new JPanel();
    JPanel panel_n = new JPanel();

    BorderLayout borderLayout_data = new BorderLayout();

    JButton button_cancel = new JButton();

    /**
     * JLabel Set of this frame
     */
    JLabel label_Ipt_Pwd_St = new JLabel();
    JLabel label_Ipt_Pwd_Ed = new JLabel();
    JLabel label_Cfm_Pwd_St = new JLabel();
    JLabel label_Cfm_Pwd_Ed = new JLabel();
    JLabel label_Encrypted_Msg = new JLabel();
    JLabel label_Encrypted_Pmpt = new JLabel();
    JLabel label_Encrypted_Abc = new JLabel();

    /**
     * JTextFidld Set of this frame
     */
    JTextField text_Ipt_Pwd = new JPasswordField();
    JTextField text_Cfm_Pwd = new JPasswordField();
    JTextField text_Encrypted_Msg = new JTextField();

    /**
     * Need layout manager
     */
    BorderLayout BodrLyot_n = new BorderLayout();
    BorderLayout BodrLyot_c = new BorderLayout();

    public InterpreterFrame()
    {
        setTitle("设置");
        contentPane.setLayout(borderLayout_data);

        /**
         * Input password
         */
        label_Ipt_Pwd_St.setText("输入密码:");
        text_Ipt_Pwd.setSize(300, 20);
        text_Ipt_Pwd.setColumns(40);
        //doc.s

        //text_Ipt_Pwd.setDocument();
        label_Ipt_Pwd_Ed.setText("(密码)");

        /**
         * confrim password
         */
        label_Cfm_Pwd_St.setText("确认密码:");
        text_Cfm_Pwd.setSize(300, 20);
        text_Cfm_Pwd.setColumns(40);
        label_Cfm_Pwd_Ed.setText("(密码)");

        /**
         * Processed encrypted Message
         */
        label_Encrypted_Msg.setText("密文代码:");
        label_Encrypted_Msg.setForeground(Color.RED);
        text_Encrypted_Msg.setColumns(50);

        label_Encrypted_Abc.setText("操作步骤:输入密码,然后确认密码,点击[生成密文]按钮。");
        label_Encrypted_Abc.setAutoscrolls(true);
        label_Encrypted_Pmpt.setText("提示:生成密文代码后,将密文代码拷贝到配置文件中保存即可。");
        label_Encrypted_Pmpt.setForeground(Color.RED);

        panel_n.setLayout(BodrLyot_n);
        panel_c.setLayout(BodrLyot_c);

        panel_Eyt_Msg.add(label_Encrypted_Msg, null);
        panel_Eyt_Msg.add(text_Encrypted_Msg, null);

        panel_Ipt_Pwd.add(label_Ipt_Pwd_St, null);
        panel_Ipt_Pwd.add(text_Ipt_Pwd, null);
        panel_Ipt_Pwd.add(label_Ipt_Pwd_Ed, null);

        panel_Cfm_Pwd.add(label_Cfm_Pwd_St, null);
        panel_Cfm_Pwd.add(text_Cfm_Pwd, null);
        panel_Cfm_Pwd.add(label_Cfm_Pwd_Ed, null);

        addButton(panel_button, "生成密文", new ActionListener()
        {
            public void actionPerformed(ActionEvent evt)
            {
                String Ipt_Pwd = text_Ipt_Pwd.getText();
                String Cfm_Pwd = text_Cfm_Pwd.getText();
                String prompt = "";

                if (Ipt_Pwd == null || Ipt_Pwd.equals(""))
                {
                    prompt = "输入密码不可以为空!";
                }
                else
                {
                    if (Cfm_Pwd == null || Cfm_Pwd.equals(""))
                    {
                        prompt = "确认密码不可以为空!";
                    }
                    else
                    {
                        if (Ipt_Pwd.equals(Cfm_Pwd))
                        {
                            prompt = EytMtic.EytMtic(Ipt_Pwd) + "=";
                        }
                        else
                        {
                            prompt = "密码输入不一致,请重新输入!";
                        }
                    }
                }

                text_Encrypted_Msg.setText(prompt);

                text_Ipt_Pwd.setText("");
                text_Ipt_Pwd.validate();
                text_Ipt_Pwd.updateUI();

                text_Cfm_Pwd.setText("");
                text_Cfm_Pwd.validate();
                text_Cfm_Pwd.updateUI();

                text_Encrypted_Msg.validate();
                text_Encrypted_Msg.updateUI();
            }
        });

        addButton(panel_button, "关闭", new ActionListener()
        {
            public void actionPerformed(ActionEvent actionEvent)
            {
                dispose();
                System.exit(0);
            }
        });

        panel_button.setBackground(SystemColor.windowBorder);

        panel_n.add(panel_Ipt_Pwd, BorderLayout.NORTH);
        panel_n.add(panel_Cfm_Pwd, BorderLayout.CENTER);
        panel_n.add(panel_button, BorderLayout.SOUTH);
        panel_c.add(panel_Eyt_Msg, BorderLayout.NORTH);
        panel_c.add(label_Encrypted_Abc, BorderLayout.CENTER);
        panel_c.add(label_Encrypted_Pmpt, BorderLayout.SOUTH);

        this.getContentPane().add(panel_n, BorderLayout.NORTH);
        this.getContentPane().add(panel_c, BorderLayout.CENTER);

        try
        {
            jbInit();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit()
            throws Exception
    {
        contentPane = (JPanel) getContentPane();
        this.getContentPane().setBackground(SystemColor.controlLtHighlight);
        this.setForeground(Color.WHITE);
        this.setBackground(Color.WHITE);
        setSize(new Dimension(600, 300));
        setTitle("Interpreter");
    }

    public void addButton(Container c, String title, ActionListener a)
    {
        JButton b = new JButton(title);
        b.setCursor(Cursor.getPredefinedCursor(12));
        b.setSize(100, 20);
        b.setBackground(Color.WHITE);
        b.setForeground(Color.BLACK);
        b.setBounds(0, 0, 0, 0);
        c.add(b);
        b.addActionListener(a);
    }

}

⌨️ 快捷键说明

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