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

📄 pop3wconfig.java

📁 一个功能比较全的JMail程序这里面付有源码
💻 JAVA
字号:
package jws.awt.net;

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

import jws.net.*;
import jws.awt.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.net.*;

public class POP3wConfig extends POP3
{
  public POP3wConfig()
    { super(); }

  public POP3wConfig
    (String server, int port, String user, String password)
  {
    super(server,port,user,password);
  }

 public void set
    (String server, int port, String user, String password)
  {
    this.server = server;
    this.port = port;
    this.user = user;
    this.password = password;
  }

  public Panel configurePanel()
  {
    final TextField tfServer = new TextField(server,30);
    final TextField tfPort = new TextField(String.valueOf(port),6);
    final TextField tfUser = new TextField(user,30);
    final TextField tfPassword = new TextField(30);

    tfPassword.setEchoChar('*');
    tfPassword.setText(password);

    Panel p = new WinPanel()
      {
        public void apply()
        {
          set(tfServer.getText(),
            Integer.parseInt(tfPort.getText()),
            tfUser.getText(),tfPassword.getText());
        }
      };

    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    p.setLayout(gridBag);

    Label l;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(1,2,1,2);
    gridBag.setConstraints(l = new Label("Server: "), c);
    p.add(l);

    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    gridBag.setConstraints(tfServer,c);
    p.add(tfServer);

    c.gridwidth = 1;
    c.weightx = 0.0;
    gridBag.setConstraints(l = new Label("Port: "), c);
    p.add(l);

    c.gridwidth = GridBagConstraints.RELATIVE;
    gridBag.setConstraints(tfPort,c);
    p.add(tfPort);

    Button defaultPortButton = new Button("Default");
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(defaultPortButton,c);
    p.add(defaultPortButton);
    defaultPortButton.addActionListener
      (
        new ActionListener()
        {
          public void actionPerformed(ActionEvent e)
            { tfPort.setText(String.valueOf(defaultPort)); }
        }
      );

    c.gridwidth = 1;
    gridBag.setConstraints(l = new Label("User: "), c);
    p.add(l);

    
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    c.gridy = GridBagConstraints.RELATIVE;
    gridBag.setConstraints(tfUser,c);
    p.add(tfUser);

    c.gridwidth = 1;
    gridBag.setConstraints(l = new Label("Password: "), c);
    p.add(l);

    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    c.gridy = GridBagConstraints.RELATIVE;
    gridBag.setConstraints(tfPassword,c);
    p.add(tfPassword);

    Panel ip = new InsetPanel(10,10,10,10);
    Panel op = new OutlinedPanel("POP3");
    ip.add(op);
    op.add(p);

    ip.validate();
    return ip;
  }

  public boolean configure(Frame parent)
  {
    final WinDialog wd =
      new WinDialog(parent,"POP3 Configuration",true);
    wd.add("Center",configurePanel());
    Panel p = new Panel();
    Button applyButton = new Button("Apply");
    p.add(applyButton);
    Button cancelButton = new Button("Cancel");
    p.add(cancelButton);
    wd.add("South",p);
    wd.pack();
    applyButton.addActionListener
      (
        new ActionListener()
        {
          public void actionPerformed(ActionEvent e)
            { wd.apply(); wd.dispose(true); }
        }
      );
    cancelButton.addActionListener
      (
        new ActionListener()
        {
          public void actionPerformed(ActionEvent e)
            { wd.dispose(); }
        }
      );
    wd.setVisible(true);
    return wd.ok;
  }

  public Vector readMail(Frame parent, boolean deleteOnServer)
    throws IOException, UnknownHostException
  {
    if (server.length() == 0
      || user.length() == 0
      || password.length() == 0)
      if (!configure(parent))
        return new Vector();
    if (server.length() > 0
      && user.length() > 0
      && password.length() > 0)
      return readMail(deleteOnServer);
    return new Vector();
  }

/*
  public static void main(String[] args)
  {
    WinFrame f = new WinFrame("POP3wConfig Demo");
    f.appMainWindow();
    f.setVisible(true);
    POP3wConfig s = new POP3wConfig();
    s.configure(f);
    f.dispose();
  }
*/
}

⌨️ 快捷键说明

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