package org.mbari.vdm.knowledgebase;


import java.awt.BorderLayout;
import java.awt.Frame;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

public class ProgressDialog extends JDialog {

	private JPanel jContentPane = null;
	private JLabel descriptionLabel = null;
	private JProgressBar progressBar = null;
    
    public ProgressDialog(Frame owner) {
        super(owner);
        initialize();
    }

	/**
	 * This is the default constructor
	 */
	public ProgressDialog() {
		this(null);
	}
    
    public void setVisible(boolean visible) {
       if (!visible) {
           setLabel("");
           getProgressBar().setString("");
           getProgressBar().setValue(0);
       }
       super.setVisible(visible);
    }

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setContentPane(getJContentPane());
        this.setSize(250, 150);
	}
    
    public void setLabel(String label) {
        descriptionLabel.setText(label);
    }

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			descriptionLabel = new JLabel();
			descriptionLabel.setText("");
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(descriptionLabel, java.awt.BorderLayout.NORTH);
			jContentPane.add(getProgressBar(), java.awt.BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes progressBar	
	 * 	
	 * @return javax.swing.JProgressBar	
	 */
	public JProgressBar getProgressBar() {
		if (progressBar == null) {
			progressBar = new JProgressBar();
		}
		return progressBar;
	}

}
