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

📄 smtpconfigdialog.java

📁 一个用java写的mail.里面的代码值得我们去研究!学习。
💻 JAVA
字号:
/*** $Id: SMTPConfigDialog.java,v 1.4 2001/05/07 12:37:22 kunugi Exp $**** Copyright (c) 2000-2001 Jeff Gay** on behalf of ICEMail.org <http://www.icemail.org>** Copyright (c) 1998-2000 by Timothy Gerard Endres** ** This program is free software.** ** You may redistribute it and/or modify it under the terms of the GNU** General Public License as published by the Free Software Foundation.** Version 2 of the license should be included with this distribution in** the file LICENSE, as well as License.html. If the license is not** included with this distribution, you may find a copy at the FSF web** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.**** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR** REDISTRIBUTION OF THIS SOFTWARE. */package org.icemail.mail;import java.awt.Container;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JButton;import javax.swing.JDialog; import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.border.EmptyBorder;import org.icemail.util.AWTUtilities; import org.icemail.util.ComponentFactory; import org.icemail.util.JFCUtilities; import org.icemail.util.UserProperties; /** * A dialog which allows the SMTP hostname to be configured. * The options are stored as part of the configuration properties. * * @see Configuration */public class SMTPConfigDialog  extends JDialog{  private JTextField hostnameField_;  /**   * Construct a dialog for configuring the SMTP hostname.   *   * @param parent parent frame to return to after disposed   */  public  SMTPConfigDialog( Frame parent ) {    super( parent, true );    establishContents();    pack();    Dimension sz = getSize();    int w = UserProperties.getProperty( "smtpConfigDialog.width", sz.width );    int h = UserProperties.getProperty( "smtpConfigDialog.height", sz.height );    setSize( w, h );    setLocation( AWTUtilities.computeDialogLocation( this ) );    addWindowListener( new IWindowAdapter() );  }//............................................................  private void  establishContents() {    setTitle( ICEMail.getBundle().getString( "SMTPConfig.Title" ) );    Container cont = getContentPane();    cont.setLayout( new GridBagLayout() );    ActionListener xlistener = new IActionListener();    int row = 0;    JPanel namePan = new JPanel();    namePan.setLayout( new GridBagLayout() );    namePan.setBorder( new EmptyBorder( 4, 4, 4, 4 ) );    AWTUtilities.constrain( cont, namePan, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.CENTER,      0, row++, 2, 1, 1.0, 0.0 );    JLabel  lbl;    lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "SMTPConfig.Hostname" );    lbl.setHorizontalAlignment( JLabel.RIGHT );    AWTUtilities.constrain( namePan, lbl, GridBagConstraints.NONE,                            GridBagConstraints.WEST, 0, 0, 1, 1, 0.0, 0.0 );    hostnameField_ =      ComponentFactory.getTextField( ICEMail.getBundle(), "SMTPConfig.Hostname", null );    AWTUtilities.constrain( namePan, hostnameField_, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.WEST, 1, 0, 1, 1, 1.0, 0.0 );    hostnameField_.setText(        UserProperties.getProperty( Configuration.P_SMTP_HOSTNAME, "" ) );    JPanel btnPan = new JPanel();    btnPan.setLayout( new GridBagLayout() );    btnPan.setBorder( JFCUtilities.StandardBorder );    AWTUtilities.constrain( cont, btnPan, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.CENTER, 0, row++, 2, 1, 1.0, 0.0 );    JButton btn;    btn = ComponentFactory.getButton( ICEMail.getBundle(), "SMTPConfig.Save",                                      xlistener, null );    AWTUtilities.constrain( btnPan, btn, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.CENTER, 0, 0, 1, 1, 1.0, 0.0 );    btn = ComponentFactory.getButton( ICEMail.getBundle(), "SMTPConfig.Cancel",                                      xlistener, null );    AWTUtilities.constrain( btnPan, btn, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.CENTER, 1, 0, 1, 1, 1.0, 0.0 );  }//............................................................  private class IActionListener    implements ActionListener  {    /**     * Invoked when an action occurs.     * <p>     * Implementation of java.awt.event.ActionListener.actionPerformed()     *     * @param event the action event that occured     */    public void    actionPerformed( ActionEvent event ) {      String xcommand = event.getActionCommand();      if ( xcommand.equals( "SAVE" ) ) {        String xhostname = hostnameField_.getText();        if ( xhostname != null && xhostname.length() > 0 ) {          Configuration.getInstance().setProperty( Configuration.P_SMTP_HOSTNAME, xhostname );          Configuration.getInstance().saveProperties();        }      } else if ( xcommand.equals( "CANCEL" ) ) {      }      dispose();    }  }//............................................................  /**   * A internal class to handle the closing of window by the window manager,   * i.e. disposing of the window properly.   */  private class IWindowAdapter    extends WindowAdapter  {    public void    windowClosing( WindowEvent event ) {      event.getWindow().dispose();    }    public void    windowActivated( WindowEvent event ) {      if ( hostnameField_ != null ) {        hostnameField_.requestFocus();        hostnameField_.selectAll();      }    }  }}

⌨️ 快捷键说明

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