KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > basic > BasicPasswordFieldUI


1 /*
2  * @(#)BasicPasswordFieldUI.java 1.30 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.plaf.basic;
8
9 import java.awt.*;
10 import javax.swing.*;
11 import javax.swing.text.*;
12 import javax.swing.event.*;
13 import javax.swing.plaf.*;
14
15
16 /**
17  * Provides the Windows look and feel for a password field.
18  * The only difference from the standard text field is that
19  * the view of the text is simply a string of the echo
20  * character as specified in JPasswordField, rather than the
21  * real text contained in the field.
22  *
23  * @author Timothy Prinzing
24  * @version 1.30 12/19/03
25  */

26 public class BasicPasswordFieldUI extends BasicTextFieldUI JavaDoc {
27
28     /**
29      * Creates a UI for a JPasswordField.
30      *
31      * @param c the JPasswordField
32      * @return the UI
33      */

34     public static ComponentUI createUI(JComponent c) {
35         return new BasicPasswordFieldUI JavaDoc();
36     }
37
38     /**
39      * Fetches the name used as a key to look up properties through the
40      * UIManager. This is used as a prefix to all the standard
41      * text properties.
42      *
43      * @return the name ("PasswordField")
44      */

45     protected String JavaDoc getPropertyPrefix() {
46     return "PasswordField";
47     }
48
49     /**
50      * Creates a view (PasswordView) for an element.
51      *
52      * @param elem the element
53      * @return the view
54      */

55     public View create(Element elem) {
56     return new PasswordView(elem);
57     }
58
59     /**
60      * Create the action map for Password Field. This map provides
61      * same actions for double mouse click and
62      * and for triple mouse click (see bug 4231444).
63      */

64
65     ActionMap createActionMap() {
66     ActionMap map = super.createActionMap();
67     if (map.get(DefaultEditorKit.selectWordAction) != null) {
68         Action a = map.get(DefaultEditorKit.selectLineAction);
69         if (a != null) {
70         map.remove(DefaultEditorKit.selectWordAction);
71         map.put(DefaultEditorKit.selectWordAction, a);
72         }
73     }
74     return map;
75     }
76
77 }
78
79
80
81
82
83
Popular Tags