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

📄 previewemailpanel.java

📁 java的简单例子
💻 JAVA
字号:
package jws.awt.net;

// Copyright 1997, John Webster Small
// All rights Reserved

import java.awt.*;
import jws.net.*;
import jws.awt.*;

public class PreviewEmailPanel extends OutlinedPanel
{
  private TextField from;
  private TextField to;
  private TextField subject;
  private TextArea  contents;

  private Label fromLabel;
  private Label toLabel;
  private Label subjectLabel;

  private void init(int rows, int cols)
  {
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridBag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(1,2,1,2);
    c.weightx = 0.0;
    gridBag.setConstraints(fromLabel = new Label("From: "), c);
    add(fromLabel);

    from = new TextField();
    from.setEditable(false);
    c.weightx = 1.0;
    gridBag.setConstraints(from,c);
    add(from);

    c.gridwidth = GridBagConstraints.RELATIVE;
    c.weightx = 0.0;
    gridBag.setConstraints(toLabel = new Label("To: "), c);
    add(toLabel);

    to = new TextField();
    to.setEditable(false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    gridBag.setConstraints(to,c);
    add(to);

    c.gridwidth = 1;
    c.weightx = 0.0;
    gridBag.setConstraints(subjectLabel = new Label("Subject: "), c);
    add(subjectLabel);

    subject = new TextField();
    subject.setEditable(false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    gridBag.setConstraints(subject,c);
    add(subject);

    contents = new TextArea(rows,cols);
    contents.setEditable(false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 1.0;
    gridBag.setConstraints(contents,c);
    add(contents);
  }

  public void addNotify()
  {
    super.addNotify();
    Font f = fromLabel.getFont();
    fromLabel.setFont
      (new Font(fromLabel.getName(),Font.BOLD,f.getSize()));
    f = toLabel.getFont();
    toLabel.setFont
      (new Font(toLabel.getName(),Font.BOLD,f.getSize()));
    f = subjectLabel.getFont();
    subjectLabel.setFont
      (new Font(subjectLabel.getName(),Font.BOLD,f.getSize()));
  }

  public void preview(Email email)
  {
    if (email == null)
      email = new Email();
    from.setText(email.getFrom());
    to.setText(email.getToAsString());
    subject.setText(email.getSubject());
    contents.setText(email.getBodyAsString());
  }

  public PreviewEmailPanel(int rows, int cols)
  {
    super("Preview");
    init(rows,cols);
  }

  public PreviewEmailPanel(int rows, int cols, Email email)
  {
    super("Preview");
    init(rows,cols);
    preview(email);
  }

/*
  public static void main(String[] args)
  {
    WinFrame f = new WinFrame
      (
        "PreviewEmailPanel Demo",
        new PreviewEmailPanel
          (4,50,
            new Email
              (
                "From: jsmall@laser.net \n" +
                "To: wdelias@access.digex.net\n" +
                "Subject: misc\n\nHi Wayne E.,\nHi!\nsdf;lk"
              )
          )
      ).appMainWindow();
    f.pack();
    f.setVisible(true);
  }
*/
}

⌨️ 快捷键说明

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