KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > SubjectView


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.composer;
17
18 import java.awt.event.FocusAdapter JavaDoc;
19 import java.awt.event.FocusEvent JavaDoc;
20
21 import org.columba.core.gui.util.CTextField;
22 import org.columba.mail.util.MailResourceLoader;
23
24
25 /**
26  * @author frd
27  *
28  * To change this generated comment edit the template variable "typecomment":
29  * Window>Preferences>Java>Templates.
30  * To enable and disable the creation of type comments go to
31  * Window>Preferences>Java>Code Generation.
32  */

33 public class SubjectView extends CTextField {
34     SubjectController controller;
35
36     public SubjectView(SubjectController controller) {
37         super(MailResourceLoader.getString("dialog", "composer",
38                 "composer_no_subject")); //$NON-NLS-1$
39
this.controller = controller;
40         addFocusListener(new FocusEventHandler());
41     }
42
43     public void installListener(SubjectController controller) {
44         getDocument().addDocumentListener(controller);
45     }
46
47     private class FocusEventHandler extends FocusAdapter JavaDoc {
48         /**
49  * Used to clear the subject field if the user clicks in it for
50  * the first time and the text contained in it is the default emtpy
51  * subject test.
52  *
53  * @param evt The focus event fired when the focus was gained by this
54  * component.
55  */

56         public void focusGained(FocusEvent JavaDoc evt) {
57             if (SubjectView.this.getText().equals(MailResourceLoader.getString(
58                             "dialog", "composer", "composer_no_subject"))) {
59                 SubjectView.this.setText("");
60             }
61         }
62     }
63 }
64
Popular Tags