gt:         btnExit = createOKButton(false);
context: // BlogBridge -- RSS feed reader, manager, and web based service
  // Copyright (C) 2002-2006 by R. Pito Salas
  //
  // This program is free software; you can redistribute it and/or modify it under
  // the terms of the GNU General Public License as published by the Free Software Foundation;
  // either version 2 of the License, or (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  // See the GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License along with this program;
  // if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  // Suite 330, Boston, MA 02111-1307 USA
  //
  // Contact: R. Pito Salas
  // mailto:pitosalas@users.sourceforge.net
  // More information: about BlogBridge
  // http://www.blogbridge.com
  // http://sourceforge.net/projects/blogbridge
  //
  // $Id: DownloadsProgressDialog.java,v 1.11 2006/12/13 19:59:28 spyromus Exp $
  //
  
  package com.salas.bb.updates.ui;
  
  import com.jgoodies.forms.builder.ButtonBarBuilder;
  import com.jgoodies.uif.AbstractDialog;
  import com.jgoodies.uif.util.SystemUtils;
  import com.salas.bb.updates.Location;
  import com.salas.bb.utils.Constants;
  import com.salas.bb.utils.i18n.Strings;
  import com.salas.bb.utils.net.IStreamProgressListener;
  import com.salas.bb.utils.net.URLInputStream;
  import com.salas.bb.utils.uif.BBFormBuilder;
  import com.salas.bb.utils.uif.ComponentsFactory;
  
  import javax.swing.*;
  import java.awt.*;
  import java.awt.event.WindowEvent;
  import java.io.IOException;
  import java.text.MessageFormat;
  import java.util.List;
  
  /**
   * Downloads progress dialog.
   */
  public class DownloadsProgressDialog extends AbstractDialog
  {
      private IStreamProgressListener progressListener;
      private Location[]              locations;
      private int                     currentDownload;
      private long                    currentRead;
      private long                    currentTotal;
      private long                    overallTotal;
      private long                    overallRead;
  
      private JProgressBar            prOverall;
      private JLabel                  lbCurrent;
      private JProgressBar            prCurrent;
      private JButton                 btnCancel;
      private JButton                 btnExit;
      private JTextArea               lbReport;
      private JPanel                  pnlReport;
      private JCheckBox               chStartInstallation;
      private boolean                 finished;
      private boolean                 exitBlogBridge;
  
      private Runnable actInstall;
      private Runnable actCancel;
      private Runnable actExit;
  
      /**
       * Creates downloads progress dialog.
       *
       * @param frame         parent frame.
       * @param aLocations    list of locations which are going to be downloaded.
       */
      public DownloadsProgressDialog(Frame frame, Location[] aLocations)
      {
          super(frame, Strings.message("updates.downloading.dialog.title"), false);
  
          locations = aLocations;
          currentDownload = -1;
          progressListener = new ProgressListener();
          finished = false;
          exitBlogBridge = false;
  
          overallRead = 0;
          overallTotal = 0;
          for (int i = 0; i < aLocations.length; i++) overallTotal += aLocations[i].getSize();
  
          initComponents();
          pack();
  
          enableEvents(AWTEvent.WINDOW_EVENT_MASK);
      }
  
      /**
       * Returns <code>TRUE</code> if a user chose to exit BB.
       *
       * @return <code>TRUE</code> to exit.
       */
      public boolean isExitBlogBridge()
      {
          return exitBlogBridge;
      }
  
      /**
       * Handles window events depending on the state of the <code>defaultCloseOperation</code>
       * property.
       *
       * @see #setDefaultCloseOperation
       */
      protected void processWindowEvent(WindowEvent e)
      {
          super.processWindowEvent(e);
  
          if (e.getID() == WindowEvent.WINDOW_OPENED) pack();
      }
  
      /**
       * Opens the dialog.
       *
       * @param installAction installation code.
       * @param cancelAction  cancelling code.
       * @param exitAction    exiting code.
       */
      public void open(Runnable installAction, Runnable cancelAction, Runnable exitAction)
      {
          actInstall = installAction;
          actCancel = cancelAction;
          actExit = exitAction;
  
          super.open();
      }
  
      /**
       * Creates page content.
       *
       * @return content.
       */
      protected JComponent buildContent()
      {
          JPanel panel = new JPanel(new BorderLayout());
  
          panel.add(createMainPanel(), BorderLayout.CENTER);
          panel.add(createButtonBar(), BorderLayout.SOUTH);
  
          return panel;
      }
  
      /**
       * Creates main panel.
       *
       * @return main panel.
       */
      private Component createMainPanel()
      {
          BBFormBuilder builder = new BBFormBuilder("max(p;200dlu)");
          builder.setDefaultDialogBorder();
  
          String msg = Strings.message(SystemUtils.IS_OS_MAC
              ? "updates.downloading.wording.mac"
              : "updates.downloading.wording");
  
          builder.appendRow("pref:grow");
          builder.append(ComponentsFactory.createWrappedMultilineLabel(msg), 1);
          builder.appendUnrelatedComponentsGapRow(2);
          builder.append(Strings.message("updates.downloading.overall.progress"), 1);
          builder.append(prOverall);
          builder.appendUnrelatedComponentsGapRow(2);
          builder.append(lbCurrent);
          builder.append(prCurrent);
          builder.append(pnlReport);
          builder.append(chStartInstallation);
          builder.appendUnrelatedComponentsGapRow(2);
  
          return builder.getPanel();
      }
  
      /** Initializes components. */
      private void initComponents()
      {
          lbReport = ComponentsFactory.createWrappedMultilineLabel("");
  
          BBFormBuilder builder = new BBFormBuilder("0:grow");
          builder.appendRelatedComponentsGapRow(1);
          builder.append(lbReport);
          pnlReport = builder.getPanel();
          pnlReport.setVisible(false);
  
          prOverall = new JProgressBar();
          lbCurrent = new JLabel();
          prCurrent = new JProgressBar();
  
          prOverall.setMinimum(0);
          prOverall.setMaximum(100);
          prOverall.setValue(0);
  
          prCurrent.setMinimum(0);
          prCurrent.setMaximum(100);
  
          chStartInstallation = ComponentsFactory.createCheckBox(Strings.message("updates.downloading.close.blogbridge.and.install.new.version"));
          chStartInstallation.setVisible(false);
  
          nextDownload();
      }
  
      /**
       * Creates button bar.
       *
       * @return button bar.
       */
      private Component createButtonBar()
      {
  