dialogrunner.java

来自「一个用java写的mail.里面的代码值得我们去研究!学习。」· Java 代码 · 共 92 行

JAVA
92 行
字号
/*** $Id: DialogRunner.java,v 1.3 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) 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.Frame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Point;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JProgressBar;import org.icemail.util.AWTUtilities;public class DialogRunner  extends Thread{  private DialogRunnable    runnable;  private JDialog           dialog;  private String            message;  public  DialogRunner( DialogRunnable runnable, Frame frame, String title, String msg ) {    super();    this.runnable = runnable;    this.dialog = new JDialog( frame, title, false );    this.message = msg;  }  public void  run() {    Container content = this.dialog.getContentPane();    content.setLayout( new GridBagLayout() );    JLabel lbl = new JLabel( this.message );    lbl.setHorizontalAlignment( JLabel.CENTER );    AWTUtilities.constrain( content, lbl, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.CENTER, 0, 0, 0, 1, 1.0, 0.0 );    JProgressBar xprogress = new JProgressBar();    xprogress.setValue( 0 );    xprogress.setMinimum( 0 );    xprogress.setMaximum( 100 );    AWTUtilities.constrain( content, xprogress, GridBagConstraints.HORIZONTAL,                            GridBagConstraints.CENTER, 0, 1, 0, 1, 1.0, 0.0 );    this.dialog.pack();    Dimension sz = this.dialog.getSize();    if ( sz.width < 350 ) {      sz.width = 350;      this.dialog.setSize( sz );    }    Point loc = AWTUtilities.computeDialogLocation( this.dialog );    this.dialog.setLocation( loc.x, loc.y );    this.runnable.run( this.dialog, xprogress );  }}

⌨️ 快捷键说明

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