001: package Schmortopf.Utility.gui.dialogs;
002:
003: /**
004: * A window, which signalizes, that the application
005: * is busy somehow.
006: *
007: */
008:
009: import java.awt.*;
010: import java.awt.event.*;
011: import javax.swing.*;
012: import javax.swing.border.*;
013:
014: import Schmortopf.Main.ResourceLoader;
015: import Schmortopf.Utility.gui.AnimatedColorPanel;
016: import Schmortopf.Utility.gui.EFCNSmoothBackgroundPanel;
017:
018: public class BusyInfoFrame extends JDialog {
019:
020: private JFrame parentFrame = null;
021: private JTextArea textArea = null;
022: private JLabel pictureLabel = null;
023:
024: private AnimatedColorPanel animatedColorPanel = null;
025: private String busyMessage;
026:
027: /**
028: * Constructs the window.
029: * Either a busyMessage or a picture must be passed.
030: * parentFrame can be null.
031: */
032: public BusyInfoFrame(final String busyMessage,
033: final ImageIcon picture, final JFrame parentFrame) {
034: super (parentFrame, false);
035: // Set the parentFrame as parent. This will keep the parentframe
036: // in the background, while this window is visible.
037:
038: this .setUndecorated(true);
039: this .getRootPane().setWindowDecorationStyle(JRootPane.NONE);
040:
041: this .parentFrame = parentFrame; // is allowed to be null
042: this .busyMessage = busyMessage;
043: this .getContentPane().setLayout(new BorderLayout());
044: int fontSize = UIManager.getFont("Label.font").getSize();
045: int gap = 1 + fontSize / 8;
046:
047: JPanel framePanel = new JPanel(new BorderLayout(1, 1));
048: Border ob = BorderFactory.createRaisedBevelBorder();
049: Border ib = BorderFactory.createEmptyBorder(gap, gap, gap, gap);
050: framePanel
051: .setBorder(BorderFactory.createCompoundBorder(ob, ib));
052:
053: EFCNSmoothBackgroundPanel mainWrapPanel = new EFCNSmoothBackgroundPanel(
054: new BorderLayout(1, 1),
055: EFCNSmoothBackgroundPanel.PanelBackGroundColorIdentifier,
056: EFCNSmoothBackgroundPanel.SmoothCenterMode);
057: framePanel.add(mainWrapPanel, BorderLayout.CENTER);
058:
059: animatedColorPanel = new AnimatedColorPanel(111);
060: animatedColorPanel
061: .setBorder(BorderFactory.createEtchedBorder());
062: mainWrapPanel.add(animatedColorPanel, BorderLayout.SOUTH);
063:
064: if (busyMessage != null) {
065: JPanel textPanel = new JPanel(new BorderLayout(0, 0));
066: textPanel.setBorder(BorderFactory.createEmptyBorder(
067: fontSize, 2 * fontSize, fontSize, 2 * fontSize));
068: textPanel.setOpaque(false);
069: mainWrapPanel.add(textPanel, BorderLayout.NORTH);
070: this .textArea = new JTextArea(busyMessage);
071: this .textArea.setEditable(false);
072: this .textArea.setForeground(UIManager
073: .getColor("Tree.foreground"));
074: this .textArea.setBackground(UIManager
075: .getColor("Tree.background"));
076: this .textArea.setOpaque(false);
077: textPanel.add(this .textArea, BorderLayout.CENTER);
078: } else {
079: this .textArea = new JTextArea("");
080: }
081:
082: this .pictureLabel = new JLabel(picture);
083: this .pictureLabel.setOpaque(false);
084: if (picture != null) {
085: mainWrapPanel.add(pictureLabel, BorderLayout.CENTER);
086: }
087:
088: this .getContentPane().add(framePanel, BorderLayout.CENTER);
089: this .pack();
090:
091: this .addWindowListener(new WindowAdapter() {
092: public void windowActivated(WindowEvent e) {
093: animatedColorPanel.setForeground(getForeground());
094: animatedColorPanel.setBackground(getBackground());
095: animatedColorPanel.activateAnimation(true);
096: }
097:
098: public void windowClosed(WindowEvent e) {
099: animatedColorPanel.activateAnimation(false);
100: }
101: });
102:
103: } // Constructor
104:
105: public void setText(String newMultiLineText) {
106: this .textArea.setText(newMultiLineText);
107: }
108:
109: public void setPicture(ImageIcon newPicture) {
110: this .pictureLabel.setIcon(newPicture);
111: }
112:
113: } // BusyInfoFrame
|