?? interpreterframe.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 + -