
// Project: webCDwriter - Network CD Writing
// Author: Jörg Haeger

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class BurnDialog extends JDialog
{
	JLabel label;
	JProgressBar bar;
	JPanel buttons;
	JPanel panel;

	BurnDialog()
	{
		super(CDcreator.mainWin, "burnDialog", true);
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

		panel = new JPanel()
		{
			public Insets getInsets() {
				return new Insets(10, 10, 10, 10);
			}
		};
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

		label = new JLabel();
		label.setAlignmentX(CENTER_ALIGNMENT);
		Dimension d = new Dimension(400, 30);
		label.setPreferredSize(d);
		panel.add(label);

		panel.add(Box.createRigidArea(new Dimension(300, 10)));

		bar = new JProgressBar();
		bar.setStringPainted(true);
		panel.add(bar);

		panel.add(Box.createRigidArea(new Dimension(300, 15)));

		JButton details = new JButton(CDcreator.i18n("details"));
		details.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				panel.remove(buttons);
				Log.getView().setPreferredSize(
					new Dimension(300, 160));
				panel.add(Log.getView());
				pack();
			}
		});
		buttons = new JPanel();
		buttons.setLayout(new FlowLayout());
		buttons.add(details);
		panel.add(buttons);

		getContentPane().add(panel);
		pack();
	}

	public void pack()
	{
		super.pack();

		// center dialog in parent
		Rectangle r = getParent().getBounds(), r1 = getBounds();
		setLocation(r.x + (r.width - r1.width) / 2,
			r.y + (r.height - r1.height) / 2);
	}

	public void setMessage(String str)
	{
		label.setText(str);
		pack();
	}

	public void setRange(int a, int b)
	{
		bar.setMinimum(a);
		bar.setMaximum(b);
	}

	public void setProgress(int n)
	{
		bar.setValue(n);
	}
}

