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

📄 mainpanel.java

📁 一个用java写的mail.里面的代码值得我们去研究!学习。
💻 JAVA
字号:
/*** $Id: MainPanel.java,v 1.6 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.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Image;import java.awt.event.ActionEvent;import java.awt.event.ActionListener; import java.io.IOException;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JPanel;import javax.swing.JSplitPane;import javax.swing.JTextField;import javax.swing.JToolBar;import org.icemail.Package; import org.icemail.util.AWTUtilities; import org.icemail.util.ComponentFactory; /** * Class MainPanel * <p> * This class implements ActionDistributor, distributing ActionEvents from other * originators to the sub-panels. */public class MainPanel  extends JPanel  implements ActionDistributor, StatusBar{  private static final int Debug_ = Package.DEBUG ? Package.getLevel( "MainPanel" ) : 0;  private JToolBar         toolBar;  private JSplitPane       splitPane;  private JTextField       statusText;  private JTextField       folderNameText;  private JTextField       numMsgsText;  private JTextField       msgNumText;// sub-panels and event distributors  private FolderTreePanel  treePanel_;  private MessagePanel     messagePanel_;  public  MainPanel() {    super();        setDoubleBuffered( true );    establishContents();    loadLayoutProperties();  }  public void  loadLayoutProperties() {    int loc = Configuration.getDividerLocation( Configuration.P_MAIN_PANEL_DIVIDER, 75 );    this.splitPane.setDividerLocation( loc );    messagePanel_.loadLayoutProperties();  }  public void  saveLayoutProperties() {    Configuration.saveDividerLocation( Configuration.P_MAIN_PANEL_DIVIDER,                                        this.splitPane.getDividerLocation() );    messagePanel_.saveLayoutProperties();  }  private void  establishContents() {    setLayout( new GridBagLayout() );    int row = 0;    int col = 0;    this.toolBar = new JToolBar();    this.toolBar.setFloatable( false );    AWTUtilities.constrain( this, this.toolBar, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.WEST,      col++, row, 1, 1, 1.0, 0.0 );    JPanel pan = new JPanel();    AWTUtilities.constrain( this, pan, GridBagConstraints.NONE,                            GridBagConstraints.EAST, col++, row++, 1, 1, 0.0, 0.0 );    messagePanel_ = new MessagePanel( this );    treePanel_ = FolderTreePanel.getInstance();    treePanel_.setMessagePanel( messagePanel_ );  // NOTE  // Populate after panels are created, since they  // are referenced by actionListeners.  //    populateToolbar( this.toolBar );    this.splitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT,                                     treePanel_, messagePanel_ );        this.splitPane.setContinuousLayout( true );    this.splitPane.setDividerSize( 3 );    AWTUtilities.constrain( this, this.splitPane, GridBagConstraints.BOTH,                            GridBagConstraints.CENTER, 0, row++, col, 1, 1.0, 1.0 );  // create the status panel for displaying folder names, number of messages, etc.    JPanel statusPan = new JPanel();    statusPan.setLayout( new GridBagLayout() );    AWTUtilities.constrain( this, statusPan, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.SOUTHWEST, 0, row++, col, 1, 1.0, 0.0 );    col = 0;    this.statusText = new JTextField();    this.statusText.setEditable( false );    AWTUtilities.constrain( statusPan, this.statusText, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.SOUTHWEST, col++, 0, 1, 1, 0.7, 0.0 );    this.folderNameText = new JTextField();    this.folderNameText.setEditable( false );    AWTUtilities.constrain( statusPan, this.folderNameText, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.SOUTHWEST, col++, 0, 1, 1, 0.15, 0.0 );    this.msgNumText = new JTextField();    this.msgNumText.setEditable( false );    AWTUtilities.constrain( statusPan, this.msgNumText, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.SOUTHWEST, col++, 0, 1, 1, 0.075, 0.0 );    this.numMsgsText = new JTextField();    this.numMsgsText.setEditable( false );    AWTUtilities.constrain( statusPan, this.numMsgsText, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.SOUTHWEST, col++, 0, 1, 1, 0.075, 0.0 );  }  private void  populateToolbar( JToolBar toolBar ) {    try {      Image iNotifyOn =        AWTUtilities.getImageResource( "/org/icemail/mail/images/notifyon.gif" );      Image iNotifyOff =        AWTUtilities.getImageResource( "/org/icemail/mail/images/notifyoff.gif" );      ImageIcon[] icons = new ImageIcon[2];      icons[0] = new ImageIcon( iNotifyOff );      icons[1] = new ImageIcon( iNotifyOn );      MailEventThread.getInstance().setNotifyIcons( icons );    } catch ( IOException ex ) {    }    IActionListener xlistener = new IActionListener();    JButton xbutton =      ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.GetMail",                                  xlistener, null );    MailEventThread.getInstance().setNotifyButton( xbutton );    toolBar.add( xbutton );      toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.CreateFolder",                                          xlistener, null );    toolBar.add( xbutton );    toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.ComposeMsg",                                          xlistener, null );    toolBar.add( xbutton );    toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.ReplyMsg",                                          xlistener, null );    toolBar.add( xbutton );    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.ReplyAllMsg",                                          xlistener, null );    toolBar.add( xbutton );    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.ForwardMsg",                                          xlistener, null );    toolBar.add( xbutton );    toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.PrintMsg",                                          xlistener, null );    toolBar.add( xbutton );    toolBar.addSeparator();    toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.CopyMsg",                                          xlistener, null );    toolBar.add( xbutton );    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.MoveMsg",                                          xlistener, null );    toolBar.add( xbutton );/*    Icon moveIcon = new ImageIcon( iMove );    Icon arwIcon = new ImageIcon( iMoveArw );    PopDownButton moveButton =      new PopDownButton( moveIcon, arwIcon, "moveBtnPopup" );    moveButton.setActionCommand( "MOVEMSG" );    moveButton.addActionListener( treePanel_ );    moveButton.setToolTipText( "Move" );    toolBar.add( moveButton );*/    toolBar.addSeparator();    toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.DeleteMsg",                                          xlistener, null );    toolBar.add( xbutton );    toolBar.addSeparator();    toolBar.addSeparator();    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.PreviousMsg",                                          xlistener, null );    toolBar.add( xbutton );    xbutton = ComponentFactory.getButton( ICEMail.getBundle(), "MainPanel.NextMsg",                                          xlistener, null );    toolBar.add( xbutton );    toolBar.addSeparator();    toolBar.addSeparator();    toolBar.add( messagePanel_.getSignedAction() );    toolBar.add( messagePanel_.getEnvelopedAction() );  }//............................................................  public void  showStatusMessage( String message ) {    this.statusText.setText( message );  }  public void  setCurrentFolderName( String folderName ) {    this.folderNameText.setText( folderName );  }  public void  setNumFolderMessages( int numMsgs ) {    this.numMsgsText.setText( "" + numMsgs );  }  public void  setCurrentMessageNum( int msgNum ) {    this.msgNumText.setText( "" + msgNum );  }//............................................................  public void  distribute( ActionEvent event ) {    if ( Package.DEBUG && Package.isTraceable( "MainPanel" ) ) {      System.out.println( "MainPanel.distribute(ae): " + event );    }    treePanel_.distribute( event );    messagePanel_.distribute( event );  }//............................................................  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 ) {      distribute( event );    }  }}

⌨️ 快捷键说明

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