001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.authentication.gui;
020:
021: import java.awt.*;
022: import java.awt.event.*;
023:
024: import javax.swing.*;
025: import javax.swing.border.*;
026:
027: import org.openharmonise.vfs.gui.*;
028:
029: /**
030: * Dialog to display a message to a user during the login sequence.
031: *
032: * @author Matthew Large
033: * @version $Revision: 1.1 $
034: *
035: */
036: public class LoginMessageDialog extends JDialog implements
037: LayoutManager, ActionListener {
038:
039: /**
040: * Simulacra logo.
041: */
042: private JLabel m_logo = null;
043:
044: /**
045: * Simulacra buildings coporate image.
046: */
047: private JLabel m_logoBuildings = null;
048:
049: /**
050: * Simulacra people coporate image.
051: */
052: private JLabel m_logoPeople = null;
053:
054: /**
055: * Simulacra files coporate image.
056: */
057: private JLabel m_logoFiles = null;
058:
059: /**
060: * Label for message to appear on the dialog.
061: */
062: private JTextArea m_messageTextArea = null;
063:
064: /**
065: * Exit button.
066: */
067: private JButton m_exitButton = null;
068:
069: /**
070: * Constructs a new login message dialog.
071: *
072: * @param frame Owning frame
073: * @throws HeadlessException
074: */
075: public LoginMessageDialog(Frame frame) throws HeadlessException {
076: super (frame, true);
077: this .setup();
078: }
079:
080: /**
081: * Configures this dialog.
082: *
083: */
084: private void setup() {
085:
086: this .setResizable(false);
087:
088: JPanel panel = new JPanel();
089: panel.setLayout(this );
090: this .getContentPane().setLayout(new BorderLayout());
091: this .getContentPane().add(panel);
092:
093: this .setTitle("Harmonise Information Manager");
094: this .setSize(500, 300);
095: panel.setBackground(new Color(224, 224, 224));
096:
097: int x = this .getGraphicsConfiguration().getBounds().width / 2
098: - this .getSize().width / 2;
099: int y = this .getGraphicsConfiguration().getBounds().height / 2
100: - this .getSize().height / 2;
101:
102: this .setLocation(x, y);
103:
104: m_logo = new JLabel();
105: m_logo
106: .setToolTipText("Connecting people and information to create knowledge");
107: m_logo.setIcon(IconManager.getInstance().getIcon(
108: "login-sim-logo.png"));
109: panel.add(m_logo);
110:
111: m_logoBuildings = new JLabel();
112: m_logoBuildings.setToolTipText("Conecting organisations");
113: m_logoBuildings.setIcon(IconManager.getInstance().getIcon(
114: "login-sim-buildings.png"));
115: panel.add(m_logoBuildings);
116:
117: m_logoPeople = new JLabel();
118: m_logoPeople.setToolTipText("Conecting people");
119: m_logoPeople.setIcon(IconManager.getInstance().getIcon(
120: "login-sim-people.png"));
121: panel.add(m_logoPeople);
122:
123: m_logoFiles = new JLabel();
124: m_logoFiles.setToolTipText("Conecting information");
125: m_logoFiles.setIcon(IconManager.getInstance().getIcon(
126: "login-sim-files.png"));
127: panel.add(m_logoFiles);
128:
129: String fontName = "Dialog";
130: int fontSize = 11;
131: Font font = new Font(fontName, Font.PLAIN, fontSize);
132: Font fontBold = new Font(fontName, Font.BOLD, fontSize);
133:
134: this .m_messageTextArea = new JTextArea();
135: this .m_messageTextArea.setOpaque(false);
136: this .m_messageTextArea.setFont(fontBold);
137: this .m_messageTextArea.setWrapStyleWord(true);
138: this .m_messageTextArea.setLineWrap(true);
139: this .m_messageTextArea.setTabSize(2);
140:
141: LineBorder lineBorder = (LineBorder) BorderFactory
142: .createLineBorder(Color.BLACK);
143:
144: m_messageTextArea.setBorder(lineBorder);
145: this .m_messageTextArea.setEditable(false);
146: panel.add(m_messageTextArea);
147:
148: m_exitButton = new JButton("Exit");
149: m_exitButton.setActionCommand("EXIT");
150: m_exitButton.setFont(font);
151: m_exitButton.addActionListener(this );
152: panel.add(m_exitButton);
153: }
154:
155: public static void main(String[] args) {
156: JFrame tempFrame = new JFrame();
157: tempFrame.setIconImage(((ImageIcon) IconManager.getInstance()
158: .getIcon("32-sim-logo.gif")).getImage());
159: LoginDialog login = new LoginDialog(tempFrame);
160: login.show();
161: }
162:
163: /**
164: * @param arg0
165: * @throws java.awt.HeadlessException
166: */
167: private LoginMessageDialog(Dialog arg0) throws HeadlessException {
168: super (arg0);
169: }
170:
171: /**
172: * @param arg0
173: * @param arg1
174: * @throws java.awt.HeadlessException
175: */
176: private LoginMessageDialog(Dialog arg0, boolean arg1)
177: throws HeadlessException {
178: super (arg0, arg1);
179: }
180:
181: /**
182: * @param arg0
183: * @throws java.awt.HeadlessException
184: */
185: private LoginMessageDialog() throws HeadlessException {
186: super ();
187: }
188:
189: /**
190: * @param arg0
191: * @param arg1
192: * @throws java.awt.HeadlessException
193: */
194: private LoginMessageDialog(Frame arg0, boolean arg1)
195: throws HeadlessException {
196: super (arg0, arg1);
197: }
198:
199: /**
200: * @param arg0
201: * @param arg1
202: * @throws java.awt.HeadlessException
203: */
204: private LoginMessageDialog(Dialog arg0, String arg1)
205: throws HeadlessException {
206: super (arg0, arg1);
207: }
208:
209: /**
210: * @param arg0
211: * @param arg1
212: * @param arg2
213: * @throws java.awt.HeadlessException
214: */
215: private LoginMessageDialog(Dialog arg0, String arg1, boolean arg2)
216: throws HeadlessException {
217: super (arg0, arg1, arg2);
218: }
219:
220: /**
221: * @param arg0
222: * @param arg1
223: * @throws java.awt.HeadlessException
224: */
225: private LoginMessageDialog(Frame arg0, String arg1)
226: throws HeadlessException {
227: super (arg0, arg1);
228: }
229:
230: /**
231: * @param arg0
232: * @param arg1
233: * @param arg2
234: * @throws java.awt.HeadlessException
235: */
236: private LoginMessageDialog(Frame arg0, String arg1, boolean arg2)
237: throws HeadlessException {
238: super (arg0, arg1, arg2);
239: }
240:
241: /**
242: * @param arg0
243: * @param arg1
244: * @param arg2
245: * @param arg3
246: * @throws java.awt.HeadlessException
247: */
248: private LoginMessageDialog(Dialog arg0, String arg1, boolean arg2,
249: GraphicsConfiguration arg3) throws HeadlessException {
250: super (arg0, arg1, arg2, arg3);
251: }
252:
253: /**
254: * @param arg0
255: * @param arg1
256: * @param arg2
257: * @param arg3
258: */
259: private LoginMessageDialog(Frame arg0, String arg1, boolean arg2,
260: GraphicsConfiguration arg3) {
261: super (arg0, arg1, arg2, arg3);
262: }
263:
264: /* (non-Javadoc)
265: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
266: */
267: public void removeLayoutComponent(Component arg0) {
268:
269: }
270:
271: /* (non-Javadoc)
272: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
273: */
274: public void layoutContainer(Container arg0) {
275: m_logo.setLocation(10, 10);
276: m_logo.setSize(new Dimension(200, 50));
277:
278: m_logoBuildings.setLocation(320, 10);
279: m_logoBuildings.setSize(new Dimension(50, 50));
280:
281: m_logoPeople.setLocation(375, 10);
282: m_logoPeople.setSize(new Dimension(50, 50));
283:
284: m_logoFiles.setLocation(430, 10);
285: m_logoFiles.setSize(new Dimension(50, 50));
286:
287: this .m_messageTextArea.setLocation(10, 70);
288: m_messageTextArea.setSize(new Dimension(470, 150));
289:
290: m_exitButton.setLocation(410, 230);
291: m_exitButton.setSize(70, 20);
292: }
293:
294: /**
295: * Sets the message text to appear on this dialog.
296: *
297: * @param sMessage Message text
298: */
299: public void setMessage(String sMessage) {
300: this .m_messageTextArea.setEditable(true);
301: this .m_messageTextArea.setText(sMessage);
302: this .m_messageTextArea.setEditable(false);
303: }
304:
305: /* (non-Javadoc)
306: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
307: */
308: public void addLayoutComponent(String arg0, Component arg1) {
309:
310: }
311:
312: /* (non-Javadoc)
313: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
314: */
315: public Dimension minimumLayoutSize(Container arg0) {
316: return new Dimension(500, 250);
317: }
318:
319: /* (non-Javadoc)
320: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
321: */
322: public Dimension preferredLayoutSize(Container arg0) {
323: return new Dimension(500, 250);
324: }
325:
326: /* (non-Javadoc)
327: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
328: */
329: public void actionPerformed(ActionEvent ae) {
330: if (ae.getActionCommand().equals("EXIT")) {
331: this .hide();
332: System.exit(0);
333: }
334: }
335:
336: }
|