?? mainframe.java
字號:
package mailbox;
import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
public class MainFrame extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JTabbedPane mainTab = new JTabbedPane();
ConfigPanel configPanel;
RecievePanel recievePanel;
SendPanel sendPanel;
JPanel helpPanel=new JPanel();
JTextArea helpArea = new JTextArea();
public MainFrame() {
try {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
File attachments=new File("附件");
File emails=new File("郵件夾");
if(!emails.exists())
emails.mkdirs();
if(!attachments.exists())
attachments.mkdirs();
if((new File("object")).exists())
{try{ObjectInputStream in2=new ObjectInputStream(new FileInputStream("object"));
recievePanel=(RecievePanel)in2.readObject();
configPanel=(ConfigPanel)in2.readObject();
in2.close();
}
catch(Exception ioe)
{
recievePanel=new RecievePanel();
configPanel=new ConfigPanel();
JOptionPane.showMessageDialog(this,"上次退出異常,現在重新加載,你的郵件請在emails文件夾里找");
}
}
else
{
recievePanel=new RecievePanel();
configPanel=new ConfigPanel();
}
User.setDisplayName(configPanel.displayField.getText());
User.setUserName(configPanel.userField.getText());
User.setPassWord(configPanel.passwordField.getText());
User.setPop3Server(configPanel.pop3Field.getText());
User.setSmtpServer(configPanel.smtpField.getText());
User.setValidateNeeded(configPanel.validateCheckBox.isSelected());
sendPanel=new SendPanel(recievePanel);
helpPanel.setLayout(null);
helpArea.setBounds(new Rectangle(60, 28, 439, 325));
helpArea.setFont(new java.awt.Font("Monospaced", 0, 14));
String word=" <SimpleMailBox2.0使用幫助>;\n1.pop3服務器推薦:pop3.163.com;pop3.sohu.com;\n pop3.sina.com.cn;pop.21cn.com;\n2.smtp服務器推薦:smtp.163.com;smtp.sohu.com;\n smtp.sina.com.cn;smtp.21cn.com;\n3.國內smtp服務器現在大部分都需要用戶名密碼驗證,上述\n 幾個都需要驗證.請在《郵箱配置》里在'是否需要驗證’\n 這一項打上勾,(默認已經選中).\n4.本程序部分采用序列化操作.為避免以外發(fā)生,所以在\n emails文件夾保存著相應的郵件.\n5.請不要刪掉各個文件夾和文件,否則,程序將重新初始化.\n6.本程序善不能正確顯示html格式的email.\n附:本人郵箱地址為postmaster@netbor.net\n " ;
helpArea.setText(word);
this.getContentPane().add(mainTab);
mainTab.setBackground(SystemColor.inactiveCaptionBorder);
mainTab.setFont(new java.awt.Font("Monospaced", 0, 14));
helpPanel.add(helpArea, null);
mainTab.addTab("使用幫助",helpPanel);
mainTab.addTab("接收郵件",recievePanel);
mainTab.addTab("發(fā)送郵件",sendPanel);
mainTab.addTab("郵箱配置",configPanel);
mainTab.setSelectedIndex(0);
this.setResizable(false);
this.setSize(580,440);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
mainTab.setSelectedIndex(0);
helpArea.requestFocus();
try{
ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream("object"));
out.writeObject(recievePanel);
out.writeObject(configPanel);
out.close();
}
catch(Exception ep){
ep.printStackTrace();
}
System.exit(0);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -