/* * @(#)QueueDialog.java * * This file is part of webCDwriter - Network CD/DVD Writing. * * Copyright (C) 1999-2005 Jörg P. M. Haeger * * webCDwriter is free software. See CDcreator.java for details. */ import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * This dialog informs the user while waiting for a resource. * * @version 20050824 * @author Jörg P. M. Haeger */ public class QueueDialog extends JPanel { JLabel label; String labelBuffer = ""; public QueueDialog(String msg, JButton cancelButton) { setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel msgPanel = new JPanel(); msgPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); msgPanel.setLayout( new BoxLayout(msgPanel, BoxLayout.Y_AXIS)); label = new JLabel(msg); label.setAlignmentX(CENTER_ALIGNMENT); msgPanel.add(label); msgPanel.add(Box.createRigidArea(new Dimension(200, 10))); label = new JLabel(labelBuffer); label.setAlignmentX(CENTER_ALIGNMENT); msgPanel.add(label); add(msgPanel); JPanel bPanel = new JPanel(); bPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); bPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); bPanel.add(cancelButton); JButton button = new JButton(CDcreator.i18n("showStatus")); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CDcreator.showServerDocument(""); } }); bPanel.add(button); add(bPanel); } public void setRank(int rank) { boolean refresh; synchronized(labelBuffer) { refresh = labelBuffer.length() == 0; labelBuffer = CDcreator.i18n("queue") + " " + rank; } if (!refresh) return; SwingUtilities.invokeLater(new Runnable() { public void run() { synchronized(labelBuffer) { label.setText(labelBuffer); labelBuffer = ""; } } }); } }