001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.core.shutdown;
017:
018: import java.awt.BorderLayout;
019: import java.awt.Dimension;
020: import java.awt.Font;
021: import java.awt.event.ActionEvent;
022: import java.awt.event.ActionListener;
023:
024: import javax.swing.BorderFactory;
025: import javax.swing.JFrame;
026: import javax.swing.JLabel;
027: import javax.swing.JPanel;
028: import javax.swing.JProgressBar;
029: import javax.swing.Timer;
030:
031: import org.columba.core.resourceloader.GlobalResourceLoader;
032: import org.columba.core.resourceloader.ImageLoader;
033:
034: /**
035: * Dialog shown while closing Columba.
036: * <p>
037: * Waits two seconds until it is visible.
038: *
039: * @author fdietz
040: */
041: public class ShutdownDialog extends JFrame implements ActionListener {
042: protected static final String RESOURCE_PATH = "org.columba.core.i18n.dialog";
043: private JProgressBar progressBar;
044: private Timer timer;
045:
046: public ShutdownDialog() throws Exception {
047: super (GlobalResourceLoader.getString(RESOURCE_PATH, "session",
048: "exit_title"));
049:
050: JLabel icon = new JLabel();
051: icon.setIcon(ImageLoader.getMiscIcon("out-of-office-48.png"));
052:
053: JLabel text = new JLabel(GlobalResourceLoader.getString(
054: RESOURCE_PATH, "session", "exit_msg"));
055: text.setFont(text.getFont().deriveFont(Font.BOLD));
056:
057: JPanel panel = new JPanel();
058:
059: panel.setLayout(new BorderLayout());
060:
061: icon.setBorder(BorderFactory.createEmptyBorder(12, 12, 6, 12));
062: text.setBorder(BorderFactory.createEmptyBorder(0, 6, 12, 12));
063:
064: progressBar = new JProgressBar();
065: progressBar.setIndeterminate(true);
066: progressBar.setPreferredSize(new Dimension(250, 20));
067:
068: JPanel bottomPanel = new JPanel(new BorderLayout());
069: bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 12,
070: 12, 12));
071: bottomPanel.add(progressBar, BorderLayout.CENTER);
072:
073: getContentPane().setLayout(new BorderLayout());
074:
075: getContentPane().add(panel, BorderLayout.CENTER);
076:
077: getContentPane().add(icon, BorderLayout.WEST);
078:
079: getContentPane().add(bottomPanel, BorderLayout.SOUTH);
080:
081: panel.add(text, BorderLayout.SOUTH);
082:
083: pack();
084:
085: setLocationRelativeTo(null);
086:
087: // wait for 2 seconds until the dialog is openened
088: timer = new Timer(2 * 1000, this );
089: timer.start();
090: }
091:
092: /**
093: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
094: */
095: public void actionPerformed(ActionEvent arg0) {
096: setVisible(true);
097: timer.stop();
098: }
099:
100: public void close() {
101: timer.stop();
102:
103: if (isVisible()) {
104: setVisible(false);
105: }
106: }
107: }
|