01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
19: import java.awt.event.FocusEvent;
20:
21: import org.columba.core.gui.util.CTextField;
22: import org.columba.mail.util.MailResourceLoader;
23:
24: /**
25: * @author frd
26: *
27: * To change this generated comment edit the template variable "typecomment":
28: * Window>Preferences>Java>Templates.
29: * To enable and disable the creation of type comments go to
30: * Window>Preferences>Java>Code Generation.
31: */
32: public class SubjectView extends CTextField {
33: SubjectController controller;
34:
35: public SubjectView(SubjectController controller) {
36: super (MailResourceLoader.getString("dialog", "composer",
37: "composer_no_subject")); //$NON-NLS-1$
38: this .controller = controller;
39: addFocusListener(new FocusEventHandler());
40: }
41:
42: public void installListener(SubjectController controller) {
43: getDocument().addDocumentListener(controller);
44: }
45:
46: private class FocusEventHandler extends FocusAdapter {
47: /**
48: * Used to clear the subject field if the user clicks in it for
49: * the first time and the text contained in it is the default emtpy
50: * subject test.
51: *
52: * @param evt The focus event fired when the focus was gained by this
53: * component.
54: */
55: public void focusGained(FocusEvent evt) {
56: if (SubjectView.this .getText().equals(
57: MailResourceLoader.getString("dialog", "composer",
58: "composer_no_subject"))) {
59: SubjectView.this .setText("");
60: }
61: }
62: }
63: }
|