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. import java.awt.*;
  9. import javax.swing.*;
  10. import javax.swing.text.*;
  11. import javax.swing.event.*;
  12. import javax.swing.plaf.*;
  13. /**
  14. * Provides the Windows look and feel for a password field.
  15. * The only difference from the standard text field is that
  16. * the view of the text is simply a string of the echo
  17. * character as specified in JPasswordField, rather than the
  18. * real text contained in the field.
  19. *
  20. * @author Timothy Prinzing
  21. * @version 1.30 12/19/03
  22. */
  23. public class BasicPasswordFieldUI extends BasicTextFieldUI {
  24. /**
  25. * Creates a UI for a JPasswordField.
  26. *
  27. * @param c the JPasswordField
  28. * @return the UI
  29. */
  30. public static ComponentUI createUI(JComponent c) {
  31. return new BasicPasswordFieldUI();
  32. }
  33. /**
  34. * Fetches the name used as a key to look up properties through the
  35. * UIManager. This is used as a prefix to all the standard
  36. * text properties.
  37. *
  38. * @return the name ("PasswordField")
  39. */
  40. protected String getPropertyPrefix() {
  41. return "PasswordField";
  42. }
  43. /**
  44. * Creates a view (PasswordView) for an element.
  45. *
  46. * @param elem the element
  47. * @return the view
  48. */
  49. public View create(Element elem) {
  50. return new PasswordView(elem);
  51. }
  52. /**
  53. * Create the action map for Password Field. This map provides
  54. * same actions for double mouse click and
  55. * and for triple mouse click (see bug 4231444).
  56. */
  57. ActionMap createActionMap() {
  58. ActionMap map = super.createActionMap();
  59. if (map.get(DefaultEditorKit.selectWordAction) != null) {
  60. Action a = map.get(DefaultEditorKit.selectLineAction);
  61. if (a != null) {
  62. map.remove(DefaultEditorKit.selectWordAction);
  63. map.put(DefaultEditorKit.selectWordAction, a);
  64. }
  65. }
  66. return map;
  67. }
  68. }