01: /*
02: * Copyright (C) 2007 Jared Alexander Spigner
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * jspigner@openjx.org
19: *
20: * JXMessageBox.java
21: *
22: * Created on June 8, 2007, 12:20 AM
23: *
24: */
25:
26: package org.openjx.display;
27:
28: import java.awt.Color;
29: import java.awt.Component;
30:
31: import javax.swing.JFrame;
32: import javax.swing.JTextArea;
33: import javax.swing.JOptionPane;
34: import javax.swing.JPanel;
35:
36: /**
37: * This class displays a simple message dialog to the user regarding anything
38: * the OpenJX application needs to tell them. It is often used for error
39: * conditions.
40: *
41: * @author Jared Spigner
42: */
43: public class JXMessageBox extends JPanel {
44:
45: /**
46: * This is the constructor for the JXMessageBox class. It creates a new
47: * instance of JXMessageBox.
48: *
49: * @param type is the type of message to be sent (ERROR_MESSAGE,
50: * INFORMATION_MESSAGE,WARNING_MESSAGE,QUESTION_MESSAGE, or
51: * PLAIN_MESSAGE).
52: * @param title is the title of the box.
53: * @param msg is the message for the user.
54: * @param parent is the parent component or null if there isn't one.
55: */
56: public JXMessageBox(int type, String title, String msg,
57: Component parent) {
58: JTextArea textArea = new JTextArea(msg);
59:
60: textArea.setLineWrap(true);
61: textArea.setBackground(this .getBackground());
62: textArea.setForeground(Color.black);
63: textArea.setSize(400, 300);
64:
65: this.add(textArea);
66:
67: JOptionPane.showConfirmDialog(parent, this, title,
68: JOptionPane.DEFAULT_OPTION, type);
69: }
70:
71: }
|