KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > synth > SynthPasswordFieldUI


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

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

25 class SynthPasswordFieldUI extends SynthTextFieldUI JavaDoc {
26
27     /**
28      * Creates a UI for a JPasswordField.
29      *
30      * @param c the JPasswordField
31      * @return the UI
32      */

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

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

54     public View create(Element elem) {
55         return new PasswordView(elem);
56     }
57
58     void paintBackground(SynthContext JavaDoc context, Graphics g, JComponent c) {
59         context.getPainter().paintPasswordFieldBackground(context, g, 0, 0,
60                                                 c.getWidth(), c.getHeight());
61     }
62
63     public void paintBorder(SynthContext JavaDoc context, Graphics g, int x,
64                             int y, int w, int h) {
65         context.getPainter().paintPasswordFieldBorder(context, g, x, y, w, h);
66     }
67
68     protected void installKeyboardActions() {
69         super.installKeyboardActions();
70         ActionMap map = SwingUtilities.getUIActionMap(getComponent());
71     if (map != null && map.get(DefaultEditorKit.selectWordAction) != null) {
72         Action a = map.get(DefaultEditorKit.selectLineAction);
73         if (a != null) {
74         map.put(DefaultEditorKit.selectWordAction, a);
75         }
76     }
77     }
78 }
79
Popular Tags