01: /*
02: * Copyright 2007 Madhav Pulipaka
03: *
04: * This file is part of Vela.
05:
06: * Vela is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (at your option) any later version.
10: *
11: * Vela is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with Vela; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19: */
20: package vela.view;
21:
22: import javax.swing.*;
23: import java.awt.*;
24: import java.awt.event.*;
25:
26: public class MessageBox extends JDialog implements ActionListener {
27:
28: private static MessageBox messageBox;
29: private JTextArea taMessage;
30: private static final int WIDTH = 525;
31: private static final int HEIGHT = 200;
32:
33: private MessageBox(Frame frame, String title, boolean isModel) {
34: super (frame, title, isModel);
35: Container container = getContentPane();
36: JButton btnOK = new JButton("Close");
37: taMessage = new JTextArea("");
38: taMessage.setEnabled(false);
39: taMessage.setBackground(Color.LIGHT_GRAY);
40: taMessage.setDisabledTextColor(new Color(128, 0, 0));
41: container.add(new JScrollPane(taMessage));
42: Dimension screenSize = Toolkit.getDefaultToolkit()
43: .getScreenSize();
44: setBounds((int) (screenSize.getWidth() / 2) - (WIDTH / 2),
45: (int) (screenSize.getHeight() / 2) - (HEIGHT / 2),
46: WIDTH, HEIGHT);
47: btnOK.addActionListener(this );
48: JPanel southPanel = new JPanel(
49: new FlowLayout(FlowLayout.CENTER));
50: southPanel.add(btnOK);
51: container.add(southPanel, BorderLayout.SOUTH);
52: taMessage.setFont(new Font("Verdana", Font.BOLD, 11));
53: btnOK.setFont(new Font("Verdana", Font.BOLD, 12));
54: //btnOK.setBackground(new Color(0,0,100));
55: //btnOK.setForeground(new Color(0,0,128));
56: }
57:
58: public static void showMessage(Frame frame, String title,
59: boolean isModel, String message) {
60: if (messageBox == null)
61: messageBox = new MessageBox(frame, title, isModel);
62: messageBox.setMessage(message);
63: messageBox.setVisible(true);
64: }
65:
66: public void setMessage(String message) {
67: taMessage.setText(message);
68: }
69:
70: public void actionPerformed(ActionEvent arg0) {
71: setVisible(false);
72: }
73:
74: }
|