?? mymessage.java
字號:
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class mymessage{
DesEncrypt pw=new DesEncrypt(); //保險柜窗口
user myuser=new user();
Frame f=new Frame("safebox ,author: csophys fedora");
Panel p=new Panel();
//Button b2=new Button("保存");
Button b1=new Button("添加");
TextArea tf=new TextArea();
String sr;
Label l1=new Label("帳號 ");
Label l2=new Label("密碼 ");
Label l3=new Label("備注 ");
Label l4=new Label("注冊時間 ");
JPanel p11=new JPanel();
JPanel p22=new JPanel();
JFrame f1=new JFrame();
JLabel l11=new JLabel("文件內(nèi)容已經(jīng)被修改,是否保存?");
JButton b11=new JButton("是");
JButton b22=new JButton("否");
/*public static void main(String args[])
{ mymessage my=new mymessage();
my.create();
}*/
void del(){
try{FileWriter fis=new FileWriter("message.saf");
String s="";pw.getKey("aadd");
String s1=pw.getEncString(s);
fis.write(s1);
fis.close();
}catch(IOException g){System.out.println(g);
}
}
void create(){
p.add(l1);p.add(l2);p.add(l4);p.add(l3);
p.add(b1);
//p.add(b2);
f.setVisible(true);
f.setResizable(false);
f.setSize(550,300);
tf.setFont(new Font("simsunn",Font.PLAIN,14));
try
{
myin();
}catch(IOException t){
System.out.println("Catch 導入"+t);
}
sr=tf.getText().trim();
f.add("North",p);
f.add("Center",tf);
f1.setLayout(new BorderLayout());
f1.add("North",p11);
f1.add("South",p22);
p11.add(l11);
p22.add(b11);p22.add(b22);
f1.setSize(250,100);
f1.setLocation(500,300);
f1.setResizable(false);
b11.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
FileWriter fis=new FileWriter("message.saf");
String s=tf.getText();
pw.getKey("aadd");
String s1=pw.getEncString(s);
fis.write(s1);
fis.close();
}catch(IOException g){System.out.println(g);
}
System.exit(0);
f.dispose();
}});
b22.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
f.dispose();}});
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{ String sr1=tf.getText().trim();
if(sr1.equals(sr))
System.exit(0);
else f1.setVisible(true);
}
});
myuser.setus.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String s=tf.getText();
String s1=myuser.UserName1.getText()+'\t'+'\t'+myuser.PassWord1.getText()+'\t'+'\t'+myuser.PassWord2.getText()+'\t'+'\t'+myuser.PassWord3.getText();
tf.setText(s+'\n'+s1);
myuser.Jset.setVisible(false);
myuser.UserName1.setText("");myuser.PassWord1.setText(""); myuser.PassWord2.setText(""); myuser.PassWord3.setText("");
}
});
b1.addActionListener(new ActionListener (){
public void actionPerformed(ActionEvent e){
myuser.Jset.setVisible(true);
}
});
/* b2.addActionListener(new ActionListener (){
public void actionPerformed (ActionEvent e) {
try
{
myout();
}catch(IOException g){
System.out.println("Catch 導出"+g);
}}});*/
}
/*void myout() throws IOException
{
FileWriter fis=new FileWriter("message.saf");
String s=tf.getText();
pw.getKey("aadd");
String s1=pw.getEncString(s);
fis.write(s1);
fis.close();
}*/
void myin() throws IOException
{ FileInputStream fis=new FileInputStream("message.saf");
BufferedReader dis=new BufferedReader(new InputStreamReader(fis));
String line=dis.readLine();
//tf.setText("");
pw.getKey("aadd");
String line1=pw.getDesString(line);
tf.setText(line1);
/*String str[]=new String[2000];
do{int i=0;
tf.append(line+'\n');
i++;
}while((line=dis.readLine())!=null);*/
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -