예제 #1
0
  /**
   * Sets whether the dialog box monitors MBT Status events. When true, the dialog box registers
   * itself as a listener for MBT Status events and displays them as they arrive. When false, the
   * dialog box is not a registered listener and does not display status events. In both cases,
   * calls to setNote() or setProgress() continue to update the dialog.
   *
   * @param onOff true if status is monitored
   */
  public void setStatusMonitored(final boolean onOff) {
    if (onOff == this.statusMonitored) {
      return; // No change
    }

    if (onOff == true) {
      Status.addStatusListener(this);
    } else {
      Status.removeStatusListener(this);
    }

    this.statusMonitored = onOff;
  }
예제 #2
0
  /**
   * Initialize the dialog box, creating it's GUI components and setting their initial values.
   *
   * @param title the dialog's title
   * @param message the general message
   */
  protected void initialize(final String title, final String message_) {
    String message = message_;
    //
    // Configure the window.
    //
    if (title == null) {
      this.setTitle("Progress");
    } else {
      this.setTitle(title);
    }

    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    //
    // Add an empty border around the dialog, and use a border
    // layout.  Prevent resizing.
    //
    this.setResizable(false);
    final Container pane = this.getContentPane();
    final JPanel content = new JPanel();
    content.setLayout(new BorderLayout());
    content.setBorder(new EmptyBorder(10, 10, 10, 10));
    pane.add(content);

    //
    // Add the general message.
    //
    if (message == null) {
      message = "";
    }
    this.messageLabel = new JLabel(message);
    final Font font = this.messageLabel.getFont();
    final Font boldFont = font.deriveFont(Font.BOLD);
    this.messageLabel.setFont(boldFont);
    content.add(this.messageLabel, BorderLayout.NORTH);

    //
    // Add the note, initially empty.
    //
    this.noteLabel = new JLabel(" ");
    content.add(this.noteLabel, BorderLayout.CENTER);

    //
    // Add the progress bar.
    //
    this.progressBar = new JProgressBar(SwingConstants.HORIZONTAL, 0, 100);
    this.progressBar.setBorderPainted(true);
    this.progressBar.setStringPainted(false);
    this.progressBar.setValue(0);
    final Dimension d = new Dimension(300, 20);
    this.progressBar.setMinimumSize(d);
    this.progressBar.setPreferredSize(d);
    content.add(this.progressBar, BorderLayout.SOUTH);

    //
    // Pack and size the dialog.
    //
    this.pack();
    this.validate();

    //
    // Listen to status events.
    //
    Status.addStatusListener(this);
  }