viewemail.java

来自「Java邮箱」· Java 代码 · 共 78 行

JAVA
78
字号
package Email.awt.net;


import java.awt.*;
import java.awt.event.*;
import Email.net.*;
import Email.awt.*;

public class ViewEmail extends WinFrame {
  private Mailbox mailbox;
  private Email email;

  private Button replyToButton = new Button("Reply to");
  private Button replyToAllButton = new Button("Reply to all");
  private Button forwardButton = new Button("Forward");

  public ViewEmail(final Mailbox mailbox, final Email email) {
    super( email.getSubject() );
    this.mailbox = mailbox;
    this.email = email;
    ViewEmailPanel vep = new ViewEmailPanel( email );
    add("Center",vep);
    Panel p = new Panel();
    p.add( replyToButton );
    p.add( replyToAllButton );
    p.add( forwardButton );
    add( "South",p );
    pack();
   
   //回复邮件
    replyToButton.addActionListener
      (
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Email em = email.replyTo(ViewEmail.this);
            new ComposeEmail( em.getSubject(),mailbox,em ).setVisible(true);
          }
        }
      );
    
    //回复邮件 
    replyToAllButton.addActionListener
      (
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Email em = email.replyToAll(ViewEmail.this);
            new ComposeEmail( em.getSubject(),mailbox,em ).setVisible(true);
          }
        }
      );
     
    //转发邮件 
    forwardButton.addActionListener
      (
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Email em = email.forward();
            new ComposeEmail( em.getSubject(),mailbox,em ).setVisible(true);
          }
        }
      );
  }

/*
  public static void main(String[] args) {
    new ViewEmail(
      new Mailbox() { public void post(Email e) {} },
      new Email
        (
          "From: wy82@21cn.com \n" +
          "To: psw82@126.com\n" +
          "Subject: Hello"
        )
      ).appMainWindow().setVisible(true);
  }
*/
}

⌨️ 快捷键说明

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