Source code: org/integralsource/monsoon/jfc/MessageBox.java
1 /*
2 * Copyright (c) 2001 John Keyes
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to:
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * $Id: MessageBox.java,v 1.2 2001/06/15 21:56:40 jbjk Exp $
20 */
21 package org.integralsource.monsoon.jfc;
22
23 /**
24 * Simple message box implementation
25 */
26 public class MessageBox
27 extends javax.swing.JDialog
28 implements java.awt.event.ActionListener
29 {
30
31 private javax.swing.JTextArea _message;
32 private javax.swing.JButton _ok;
33 private javax.swing.border.TitledBorder _border;
34
35 /**
36 * Constructor
37 */
38 public MessageBox(java.awt.Dialog dialog) {
39 super(dialog,true);
40 __init();
41 setResizable(false);
42 setLocation(dialog.getLocation().x+30,
43 dialog.getLocation().y+30);
44 }
45
46 /**
47 * Constructor
48 */
49 public MessageBox(java.awt.Frame frame) {
50 super(frame,true);
51 __init();
52 setResizable(false);
53 setLocation(frame.getLocation().x+30,
54 frame.getLocation().y+30);
55 }
56
57 /**
58 * Initialise gui components
59 */
60 private void __init() {
61 java.awt.Container $contentPane = getContentPane();
62 java.awt.GridBagLayout $layout
63 = new java.awt.GridBagLayout();
64 $contentPane.setLayout($layout);
65
66 java.awt.GridBagConstraints $constraints
67 = new java.awt.GridBagConstraints();
68
69 // create an insets
70 java.awt.Insets $insets = new java.awt.Insets(0,0,0,0);
71
72 _message = new javax.swing.JTextArea();
73 _message.setEditable(false);
74 _message.setBackground($contentPane.getBackground());
75 _border = new javax.swing.border.TitledBorder(
76 new javax.swing.border.EtchedBorder(),
77 "Details");
78 _border.setTitleColor(java.awt.Color.black);
79 _message.setBorder(_border);
80 $constraints.gridx = 0;
81 $constraints.gridy = 0;
82 $constraints.fill = $constraints.BOTH;
83 $constraints.ipadx = 3;
84 $constraints.ipady = 3;
85 $insets.top = 10;
86 $insets.bottom = 5;
87 $insets.left = 10;
88 $insets.right = 10;
89 $constraints.insets = $insets;
90 $layout.setConstraints(_message,$constraints);
91 $contentPane.add(_message);
92
93 _ok = new javax.swing.JButton("OK");
94 _ok.addActionListener(this);
95 _ok.addMouseListener(new org.integralsource.monsoon.jfc.ButtonEmphasiser());
96 $constraints.gridy = 1;
97 $constraints.fill = $constraints.NONE;
98 $layout.setConstraints(_ok,$constraints);
99 $contentPane.add(_ok);
100 }
101
102 public void show(java.lang.String title, java.lang.String message) {
103 setTitle(title);
104 if("About".equals(title)) {
105 _border.setTitle("About");
106 }
107 _message.setText(message);
108 pack();
109 setVisible(true);
110 }
111
112 /**
113 * Action listener for OK button
114 */
115 public void actionPerformed(java.awt.event.ActionEvent evt) {
116 setVisible(false);
117 dispose();
118 }
119
120 }