KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > authentication > gui > LoginMessageDialog


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.authentication.gui;
20
21 import java.awt.*;
22 import java.awt.event.*;
23
24 import javax.swing.*;
25 import javax.swing.border.*;
26
27 import org.openharmonise.vfs.gui.*;
28
29
30 /**
31  * Dialog to display a message to a user during the login sequence.
32  *
33  * @author Matthew Large
34  * @version $Revision: 1.1 $
35  *
36  */

37 public class LoginMessageDialog extends JDialog implements LayoutManager, ActionListener {
38
39     /**
40      * Simulacra logo.
41      */

42     private JLabel m_logo = null;
43     
44     /**
45      * Simulacra buildings coporate image.
46      */

47     private JLabel m_logoBuildings = null;
48     
49     /**
50      * Simulacra people coporate image.
51      */

52     private JLabel m_logoPeople = null;
53     
54     /**
55      * Simulacra files coporate image.
56      */

57     private JLabel m_logoFiles = null;
58     
59     /**
60      * Label for message to appear on the dialog.
61      */

62     private JTextArea m_messageTextArea = null;
63     
64     /**
65      * Exit button.
66      */

67     private JButton m_exitButton = null;
68
69     /**
70      * Constructs a new login message dialog.
71      *
72      * @param frame Owning frame
73      * @throws HeadlessException
74      */

75     public LoginMessageDialog(Frame frame) throws HeadlessException {
76         super(frame, true);
77         this.setup();
78     }
79     
80     /**
81      * Configures this dialog.
82      *
83      */

84     private void setup() {
85             
86         this.setResizable(false);
87         
88         JPanel panel = new JPanel();
89         panel.setLayout(this);
90         this.getContentPane().setLayout(new BorderLayout());
91         this.getContentPane().add(panel);
92         
93         this.setTitle("Harmonise Information Manager");
94         this.setSize(500,300);
95         panel.setBackground(new Color(224,224,224));
96         
97         int x = this.getGraphicsConfiguration().getBounds().width/2-this.getSize().width/2;
98         int y = this.getGraphicsConfiguration().getBounds().height/2-this.getSize().height/2;
99         
100         this.setLocation(x, y);
101         
102         m_logo = new JLabel();
103         m_logo.setToolTipText("Connecting people and information to create knowledge");
104         m_logo.setIcon( IconManager.getInstance().getIcon("login-sim-logo.png") );
105         panel.add(m_logo);
106         
107         m_logoBuildings = new JLabel();
108         m_logoBuildings.setToolTipText("Conecting organisations");
109         m_logoBuildings.setIcon( IconManager.getInstance().getIcon("login-sim-buildings.png") );
110         panel.add(m_logoBuildings);
111         
112         m_logoPeople = new JLabel();
113         m_logoPeople.setToolTipText("Conecting people");
114         m_logoPeople.setIcon( IconManager.getInstance().getIcon("login-sim-people.png") );
115         panel.add(m_logoPeople);
116         
117         m_logoFiles = new JLabel();
118         m_logoFiles.setToolTipText("Conecting information");
119         m_logoFiles.setIcon( IconManager.getInstance().getIcon("login-sim-files.png") );
120         panel.add(m_logoFiles);
121         
122         String JavaDoc fontName = "Dialog";
123         int fontSize = 11;
124         Font font = new Font(fontName, Font.PLAIN, fontSize);
125         Font fontBold = new Font(fontName, Font.BOLD, fontSize);
126         
127         this.m_messageTextArea = new JTextArea();
128         this.m_messageTextArea.setOpaque(false);
129         this.m_messageTextArea.setFont(fontBold);
130         this.m_messageTextArea.setWrapStyleWord(true);
131         this.m_messageTextArea.setLineWrap(true);
132         this.m_messageTextArea.setTabSize(2);
133
134         LineBorder lineBorder = (LineBorder) BorderFactory.createLineBorder(Color.BLACK);
135
136         m_messageTextArea.setBorder( lineBorder );
137         this.m_messageTextArea.setEditable(false);
138         panel.add(m_messageTextArea);
139         
140         m_exitButton = new JButton("Exit");
141         m_exitButton.setActionCommand("EXIT");
142         m_exitButton.setFont(font);
143         m_exitButton.addActionListener(this);
144         panel.add(m_exitButton);
145     }
146     
147     public static void main(String JavaDoc[] args) {
148         JFrame tempFrame = new JFrame();
149         tempFrame.setIconImage( ((ImageIcon)IconManager.getInstance().getIcon("32-sim-logo.gif")).getImage() );
150         LoginDialog login = new LoginDialog(tempFrame);
151         login.show();
152     }
153     
154     
155     
156     
157     
158     
159     
160     
161
162     /**
163      * @param arg0
164      * @throws java.awt.HeadlessException
165      */

166     private LoginMessageDialog(Dialog arg0) throws HeadlessException {
167         super(arg0);
168     }
169
170     /**
171      * @param arg0
172      * @param arg1
173      * @throws java.awt.HeadlessException
174      */

175     private LoginMessageDialog(Dialog arg0, boolean arg1) throws HeadlessException {
176         super(arg0, arg1);
177     }
178
179     /**
180      * @param arg0
181      * @throws java.awt.HeadlessException
182      */

183     private LoginMessageDialog() throws HeadlessException {
184         super();
185     }
186
187     /**
188      * @param arg0
189      * @param arg1
190      * @throws java.awt.HeadlessException
191      */

192     private LoginMessageDialog(Frame arg0, boolean arg1) throws HeadlessException {
193         super(arg0, arg1);
194     }
195
196     /**
197      * @param arg0
198      * @param arg1
199      * @throws java.awt.HeadlessException
200      */

201     private LoginMessageDialog(Dialog arg0, String JavaDoc arg1) throws HeadlessException {
202         super(arg0, arg1);
203     }
204
205     /**
206      * @param arg0
207      * @param arg1
208      * @param arg2
209      * @throws java.awt.HeadlessException
210      */

211     private LoginMessageDialog(Dialog arg0, String JavaDoc arg1, boolean arg2)
212         throws HeadlessException {
213         super(arg0, arg1, arg2);
214     }
215
216     /**
217      * @param arg0
218      * @param arg1
219      * @throws java.awt.HeadlessException
220      */

221     private LoginMessageDialog(Frame arg0, String JavaDoc arg1) throws HeadlessException {
222         super(arg0, arg1);
223     }
224
225     /**
226      * @param arg0
227      * @param arg1
228      * @param arg2
229      * @throws java.awt.HeadlessException
230      */

231     private LoginMessageDialog(Frame arg0, String JavaDoc arg1, boolean arg2)
232         throws HeadlessException {
233         super(arg0, arg1, arg2);
234     }
235
236     /**
237      * @param arg0
238      * @param arg1
239      * @param arg2
240      * @param arg3
241      * @throws java.awt.HeadlessException
242      */

243     private LoginMessageDialog(
244         Dialog arg0,
245         String JavaDoc arg1,
246         boolean arg2,
247         GraphicsConfiguration arg3)
248         throws HeadlessException {
249         super(arg0, arg1, arg2, arg3);
250     }
251
252     /**
253      * @param arg0
254      * @param arg1
255      * @param arg2
256      * @param arg3
257      */

258     private LoginMessageDialog(
259         Frame arg0,
260         String JavaDoc arg1,
261         boolean arg2,
262         GraphicsConfiguration arg3) {
263         super(arg0, arg1, arg2, arg3);
264     }
265
266     /* (non-Javadoc)
267      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
268      */

269     public void removeLayoutComponent(Component arg0) {
270
271     }
272
273     /* (non-Javadoc)
274      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
275      */

276     public void layoutContainer(Container arg0) {
277         m_logo.setLocation(10,10);
278         m_logo.setSize(new Dimension(200,50));
279
280         m_logoBuildings.setLocation(320,10);
281         m_logoBuildings.setSize(new Dimension(50,50));
282
283         m_logoPeople.setLocation(375,10);
284         m_logoPeople.setSize(new Dimension(50,50));
285
286         m_logoFiles.setLocation(430,10);
287         m_logoFiles.setSize(new Dimension(50,50));
288         
289         this.m_messageTextArea.setLocation(10, 70);
290         m_messageTextArea.setSize(new Dimension(470, 150));
291         
292         m_exitButton.setLocation(410, 230);
293         m_exitButton.setSize(70,20);
294     }
295     
296     /**
297      * Sets the message text to appear on this dialog.
298      *
299      * @param sMessage Message text
300      */

301     public void setMessage(String JavaDoc sMessage) {
302         this.m_messageTextArea.setEditable(true);
303         this.m_messageTextArea.setText(sMessage);
304         this.m_messageTextArea.setEditable(false);
305     }
306
307     /* (non-Javadoc)
308      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
309      */

310     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
311
312     }
313
314     /* (non-Javadoc)
315      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
316      */

317     public Dimension minimumLayoutSize(Container arg0) {
318         return new Dimension(500,250);
319     }
320
321     /* (non-Javadoc)
322      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
323      */

324     public Dimension preferredLayoutSize(Container arg0) {
325         return new Dimension(500,250);
326     }
327
328     /* (non-Javadoc)
329      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
330      */

331     public void actionPerformed(ActionEvent ae) {
332         if(ae.getActionCommand().equals("EXIT")) {
333             this.hide();
334             System.exit(0);
335         }
336     }
337
338 }
339
Popular Tags