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

📄 composeframe.java

📁 一个用java写的mail.里面的代码值得我们去研究!学习。
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            String ad = (String) descV.elementAt(ai);            attachComboBox_.addItem( ad );          }        }        headers_ = MessageUtilities.getHeaders( xnew );        headers_.removeHeader( "from" );        headers_.removeHeader( "to" );        headers_.removeHeader( "cc" );        headers_.removeHeader( "bcc" );        headers_.removeHeader( "subject" );        headers_.removeHeader( "content-type" );      // apply any adornments        if ( xprefix != null ) {          prefixMessageText( xprefix );        }        if ( xenclosure != null ) {          encloseMessageText( xenclosure );        }        if ( MessageUtilities.isHighPriority( originalMessage_ ) ) {          priorityButton_.rotate( 1 );        } else if ( MessageUtilities.isLowPriority( originalMessage_ ) ) {          priorityButton_.rotate( 3 );        }      } else {      // no supplied message, just provide a      // from address to start with        fromText_.setText( MessageUtilities.getDefaultFromString() );      }    // add the custom headers ( X-Mailer, Organization... )      String orgStr = UserProperties.getProperty( Configuration.P_ORGANIZATION, null );      String mailerStr =        "ICEMail (rel " + ICEMail.getVersionString() + ") <http://www.icemail.org/>";      headers_.setHeader( "X-Mailer", mailerStr );      if ( orgStr != null && orgStr.length() > 0 ) {        headers_.setHeader( "Organization", orgStr );      }    } catch ( MessagingException xex ) {      System.out.println( "ComposeFrame.setMessage() failed: " + xex.toString() );    }  }  private String  getReplyPrefix( Message msg ) {    String xresult =      UserProperties.getProperty( Configuration.P_COMPOSE_REPLY_PREFIX, null );    if ( xresult != null && xresult.length() > 0 ) {    // FIXME    // additional parameter replacements could be performed on the string    } else {      xresult = null;    }    return xresult;  }  private String  getReplyEnclosure( Message msg ) {    String xresult =      UserProperties.getProperty( Configuration.P_COMPOSE_REPLY_ENCLOSURE, null );    if ( xresult != null && xresult.length() > 0 ) {    // FIXME additional parameter replacements    //        could be performed on the string    } else {      xresult = null;    }    return xresult;  }  private String  getForwardPrefix( Message msg ) {    String xresult =      UserProperties.getProperty( Configuration.P_COMPOSE_FORWARD_PREFIX, null );    if ( xresult != null && xresult.length() > 0 ) {    // FIXME    // additional parameter replacements    // could be performed on the string    } else {      xresult = null;    }    return xresult;  }  private String  getForwardEnclosure( Message msg ) {    String xresult =      UserProperties.getProperty( Configuration.P_COMPOSE_FORWARD_ENCLOSURE, null );    if ( xresult != null && xresult.length() > 0 ) {    // FIXME    // additional parameter replacements could be performed on the string    } else {      xresult = null;    }    return xresult;  }// FIXME// I want to be able to use variables like {From} and {To}// and {Date} to insert header values into this string...  private void  prefixMessageText( String prefix ) {    String xcontents = messageText_.getText();    if ( xcontents == null || xcontents.length() == 0 )      return;    try {      BufferedReader xreader =        new BufferedReader( new StringReader( xcontents ) );      StringBuffer xnew = new StringBuffer( xcontents.length() );      for ( String xline = null; ( xline = xreader.readLine() ) != null ; ) {        xnew.append( prefix + xline + '\n' );      }      messageText_.setText( xnew.toString() );    } catch( IOException xex ) { }  }  // FIXME  // I want to be able to use variables like {From} and {To}  // and {Date} to insert header values into this string...  private void  encloseMessageText( String enclosure ) {    String xreplacement = '\n' + enclosure + "\n\n";  // prefix the message with the enclosure    messageText_.setCaretPosition( 0 );    messageText_.moveCaretPosition( 0 );    messageText_.replaceSelection( xreplacement );  // postfix the message with the enclosure    int end = messageText_.getDocument().getEndPosition().getOffset();    messageText_.setCaretPosition( end - 1 );    messageText_.moveCaretPosition( end - 1 );    messageText_.replaceSelection( xreplacement );  }//............................................................  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 ) {    // FIXME determine which commands need to call the following:    // getInputContext().endComposition();      String command = event.getActionCommand();      if ( command.equals( "CLOSE" ) ) {        closeWindow();      } else if ( command.equals( sendButton_.getActionCommand() ) ) {        sendMessage();      } else if ( command.equals( printButton_.getActionCommand() ) ) {        printMessage();      } else if ( command.startsWith( "ADDR:" ) ) {        String addrStr = null;        String addrName = command.substring( 5 );        addrStr = UserProperties.getProperty( ("address." + addrName), null );        if ( addrStr != null ) {          pasteAddress( addrStr );        }      } else if ( command.startsWith( "SIGN:" ) ) {        String sigStr = null;        String sigName = command.substring( 5 );        if ( sigName.equals( "DEFAULT" ) ) {          sigStr = UserProperties.getProperty( "signature.default", null );        } else if ( sigName.equals( "NONE" ) ) {          sigStr = "";        } else {          sigStr = UserProperties.getProperty( ("signature." + sigName), null );        }        if ( sigStr != null ) {          setSignature( sigStr );        }      } else if ( command.equals( "HEADERS" ) ) {        editHeaders();      } else if ( command.equals( attachButton_.getActionCommand() ) ) {        String text = messageText_.getSelectedText();        if ( text != null && text.length() > 0 ) {          attachSelection( text );        } else {          attachFile();        }      } else if ( command.equals( "PREFIX" ) ) {        prefixSelection();      } else if ( command.equals( detachButton_.getActionCommand() ) ) {        detachFile();      } else if ( command.equals( "CUT" ) ) {        if ( currentFocus_ != null ) {          currentFocus_.cut();        }      } else if ( command.equals( "COPY" ) ) {        if ( currentFocus_ != null ) {          currentFocus_.copy();        }      } else if ( command.equals( "PASTE" ) ) {        if ( currentFocus_ != null ) {          currentFocus_.paste();        }      } else if ( command.equals( "PASTEFILE" ) ) {        if ( messageText_ != null ) {          pasteFile();        }      } else if ( command.equals( "UNDO" ) ) {        if ( messageUndo_ != null && messageUndo_.canUndoOrRedo() ) {          messageUndo_.undoOrRedo();        }      } else if ( command.equals( "CHARSET" ) ) {        int xitem = charsets_.indexOf( charsetLbl_.getText() ) + 1;        if ( xitem >= charsets_.size() ) {          xitem = 0;        }        charsetLbl_.setText( (String)charsets_.elementAt( xitem ) );      } else if ( command.equals( "SIGNON" ) ) {      } else if ( command.equals( "SIGNCLEAR" ) ) {      } else if ( command.equals( "SIGNOFF" ) ) {      } else if ( command.equals( "ENCRYPTON" ) ) {      } else if ( command.equals( "ENCRYPTOFF" ) ) {      } else if ( command.equals( "HIGHPRIORITY" ) ) {        headers_.setHeader( "X-Priority", "1" );        headers_.setHeader( "Importance", "high" );      } else if ( command.equals( "NORMALPRIORITY" ) ) {        headers_.removeHeader( "X-Priority" );        headers_.removeHeader( "Importance" );      } else if ( command.equals( "LOWPRIORITY" ) ) {        headers_.setHeader( "Importance", "low" );        headers_.setHeader( "X-Priority", "5" );      } else {        System.err.println( "ComposeFrame.actionPerformed() - unknown command '" +                            command + "'" );      }    }  }//............................................................    private class IWindowDisposer      implements Runnable    {      public void run() {        setVisible( false );        setEnabled( false );      }    }//............................................................    private class IWindowAdapter      extends WindowAdapter    {      public void      windowClosing( WindowEvent e )      {        //System.out.println( "windowClosing(e)" );        closeWindow();      }    }//............................................................    private class IFocusListener      implements FocusListener    {      /**       * <p>       * Implementation of java.awt.event.FocusListener.focusLost()       */      public void      focusLost( FocusEvent event ) { }      /**       * <p>       * Implementation of java.awt.event.FocusListener.focusGained()       */      public void      focusGained( FocusEvent event ) {        Object comp = event.getSource();        if ( comp instanceof JTextField || comp instanceof JTextPane ) {          currentFocus_ = (JTextComponent)event.getSource();        } else {          currentFocus_ = null;        }      }    }//............................................................    private class IUndoableEditListener      implements UndoableEditListener    {      public void      undoableEditHappened( UndoableEditEvent event ) {        modified_ = true;      }    }//............................................................    private class IMouseAdapter      extends MouseAdapter    {      private boolean       isPopupClick = false;      private JPopupMenu    popup = null;      public      IMouseAdapter( JPopupMenu popup ) {        super();        this.popup = popup;      }      public void      mousePressed( MouseEvent event ) {        this.isPopupClick = false;        if ( event.isPopupTrigger() ) {          this.isPopupClick = true;          Point pt =            JFCUtilities.computePopupLocation( event, charsetLbl_, popup );          this.popup.show( charsetLbl_, pt.x, pt.y );        }      }      public void      mouseReleased( MouseEvent event ) {        if ( this.isPopupClick ) return;        if ( event.isPopupTrigger() ) {          this.isPopupClick = true;          Point pt =            JFCUtilities.computePopupLocation( event, charsetLbl_, popup );          this.popup.show( charsetLbl_, pt.x, pt.y );        }      }      public void      mouseClicked( MouseEvent event ) {        if ( this.isPopupClick ) {          this.isPopupClick = false;          return;        }        if ( event.getClickCount() == 2 ) {          processDoubleClick();        }      }      private void      processDoubleClick() { }    }//............................................................    private class IAbstractAction    extends AbstractAction    {      private String charset_;      public      IAbstractAction( String charset ) {        super( charset );        charset_ = charset;      }      public void      actionPerformed( ActionEvent  evt ) {        int xitem = charsets_.indexOf( charset_ ) + 1;        if ( xitem >= charsets_.size() )          xitem = 0;        charsetLbl_.setText( charset_ );      }    }}

⌨️ 快捷键说明

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