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

📄 composemgr.java

📁 一个用java写的mail.里面的代码值得我们去研究!学习。
💻 JAVA
字号:
/*** $Id: ComposeMgr.java,v 1.4 2001/05/07 12:37:21 kunugi Exp $**** Copyright (c) 2000-2001 Jeff Gay** on behalf of ICEMail.org <http://www.icemail.org>** Copyright (c) 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.util.Vector;import java.util.Enumeration;import javax.mail.Message;import org.icemail.Package;/** * This is a manager for all composition frames. * <p> * At this time, JFrame is known to leak memory, so all ComposeFrames * are managed, and re-used. * <p> * Note: A side effect is that composition frames are faster now. * * @see ComposeFrame */public class ComposeMgr{  private static final int Debug_ = Package.DEBUG ? Package.getLevel( "ComposeMgr" ) : 0;  private static ComposeMgr Instance_ = null;  private Vector            frames_ = null;  /**   * Default constructor, private to disable multiple instantiations.   */  private  ComposeMgr()  { }  /**   * Get the SINGLE instance of the manager, creating it if necessary.   *   * @return the SINGLE instance of the manager   */  public static synchronized ComposeMgr  getInstance() {    if ( ComposeMgr.Instance_ == null ) {      ComposeMgr.Instance_ = new ComposeMgr();      ComposeMgr.Instance_.frames_ = new Vector();    }    return ComposeMgr.Instance_;  }  /**   * Get a composition frame for use in editing a message, creating it if necessary.   *   * @return a composition frame for use in editing a message   */  public synchronized ComposeFrame  getComposeFrame() {    if ( Package.DEBUG && Package.isTraceable( "ComposeMgr" ) ) {      System.out.println( "ComposeMgr.getComposeFrame(): " + frames_.size() );    }    ComposeFrame result = null;    for ( int i = 0, sz = frames_.size() ; i < sz ; ++i ) {      ComposeFrame xframe = (ComposeFrame)frames_.elementAt( i );      if ( ! xframe.isEnabled() ) {        if ( Package.DEBUG && Debug_ > 0 ) {          System.out.println( "ComposeMgr.getComposeFrame(): re-using disabled ComposeFrame" );        }        result = xframe;        break;      }    }    if ( result == null ) {      if ( Package.DEBUG && Debug_ > 0 ) {        System.out.println( "ComposeMgr.getComposeFrame(): creating new ComposeFrame" );      }      ComposeFrame xframe = new ComposeFrame();      frames_.addElement( xframe );      result = xframe;    }    return result;  }  /**   * Determine if there are compositions being performed.   * Composition frames that are 'enabled' are considered to be in use.   * <p>   * Note: Because ComposeFrame's are disabled by a separate thread, this   * method may return true if a frame has just been closed.   *   * @return true if any composition frame is being used   */  public synchronized boolean  hasOpenWindows() {    if ( Package.DEBUG && Package.isTraceable( "ComposeMgr" ) ) {      System.err.println( "ComposeMgr.hasOpenWindows()" );    }    boolean result = false;    for ( int i = 0, sz = frames_.size() ; i < sz ; ++i ) {      ComposeFrame xframe = (ComposeFrame)frames_.elementAt( i );      if ( xframe.isEnabled() ) {        result = true;        break;      }    }    return result;  }  /**   * Utility method to close all composition frames before exiting.   *   * @see ICEMail   */  public synchronized void  closeAllFrames() {    if ( Package.DEBUG && Package.isTraceable( "ComposeMgr" ) ) {      System.err.println( "ComposeMgr.closeAllFrames()" );    }    for ( int i = 0, sz = frames_.size() ; i < sz ; ++i ) {      ComposeFrame xframe = (ComposeFrame)frames_.elementAt( i );      if ( xframe.isEnabled() ) {        xframe.toFront();        xframe.dispose();      }    }  }}

⌨️ 快捷键说明

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