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

📄 propertiesdialog.java

📁 一个用java写的mail.里面的代码值得我们去研究!学习。
💻 JAVA
字号:
/*** $Id: PropertiesDialog.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.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Font;import java.awt.Frame;import java.awt.Insets;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.mail.Part;import javax.mail.MessagingException;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.border.EmptyBorder;import org.icemail.util.AWTUtilities; import org.icemail.util.ComponentFactory; import org.icemail.util.UserProperties; /** * A dialog which displays that attribrutes of a part as strings. * NOTE: Messages are also parts in the JavaMail hierachy. */public class PropertiesDialog  extends JDialog{  /**   * Construct a dialog for displaying the given part's attribrutes.   *   * @param parent parent frame to return to after disposed   * @param part the part from which to obtain the attributes   */  public  PropertiesDialog( Frame parent, Part part, boolean recurse ) {    super( parent, true );    establishContents( part, recurse );    pack();    Dimension sz = getPreferredSize();    sz.width = UserProperties.getProperty( "propertiesDialog.width", sz.width );    sz.height = UserProperties.getProperty( "propertiesDialog.height", sz.height );    Point location = AWTUtilities.computeDialogLocation( this, sz.width, sz.height );    setSize( sz );    setLocation( location );  }//............................................................  private void  establishContents( Part part, boolean recurse ) {  // create the contents of the text area from the contents of the part    StringBuffer xbuffer = new StringBuffer( 256 );    try {    MessageUtilities.getPartDescription( part, xbuffer, "", recurse );    } catch ( MessagingException xex ) {      xbuffer.append( "MessagingException: " + xex );    }  // establish the contents of the dialog    setTitle( ICEMail.getBundle().getString( "Properties.Title" ) );    Container xcontentpane = getContentPane();    xcontentpane.setLayout( new BorderLayout() );    JPanel xpanel = new JPanel();    xpanel.setLayout( new GridBagLayout() );    xpanel.setBorder( new EmptyBorder( 3, 3, 3, 3 ) );    xcontentpane.add( BorderLayout.CENTER, xpanel );    JLabel xlabel;    xlabel = ComponentFactory.getLabel( ICEMail.getBundle(), "Properties" );    AWTUtilities.constrain( xpanel, xlabel, GridBagConstraints.NONE,                            GridBagConstraints.NORTH, 0, 0, 1, 1, 0.0, 1.0,                            new Insets( 8, 8, 8, 8 ) );    JTextArea xtextarea = new JTextArea( xbuffer.toString() );    xtextarea.setEditable( false );    xtextarea.setFont( UserProperties.getFont( "propertiesDialog.font",                                               new Font( "Dialog", Font.BOLD, 12 ) ) );    JScrollPane scroller = new JScrollPane( xtextarea );    scroller.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );    AWTUtilities.constrain( xpanel, scroller, GridBagConstraints.BOTH,                            GridBagConstraints.NORTH, 1, 0, 1, 1, 1.0, 1.0 );    JButton btn;    btn = ComponentFactory.getButton( ICEMail.getBundle(), "Properties",                                      new IActionListener(), null );    AWTUtilities.constrain( xpanel, btn, GridBagConstraints.NONE,                            GridBagConstraints.EAST, 0, 1, 2, 1, 1.0, 0.0,                            new Insets( 12, 8, 8, 8 ) );  }//............................................................  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 command = event.getActionCommand();      if ( command.compareTo( "OK" ) == 0 ) {      }      dispose();    }  }}

⌨️ 快捷键说明

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