1. /*
  2. * @(#)BasicTextFieldUI.java 1.78 01/11/29
  3. *
  4. * Copyright 2002 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 java.awt.event.KeyEvent;
  10. import java.awt.event.FocusEvent;
  11. import java.awt.event.InputEvent;
  12. import javax.swing.*;
  13. import javax.swing.border.*;
  14. import javax.swing.event.*;
  15. import javax.swing.text.*;
  16. import javax.swing.plaf.*;
  17. /**
  18. * Basis of a look and feel for a JTextField.
  19. * <p>
  20. * <strong>Warning:</strong>
  21. * Serialized objects of this class will not be compatible with
  22. * future Swing releases. The current serialization support is appropriate
  23. * for short term storage or RMI between applications running the same
  24. * version of Swing. A future release of Swing will provide support for
  25. * long term persistence.
  26. *
  27. * @author Timothy Prinzing
  28. * @version 1.78 11/29/01
  29. */
  30. public class BasicTextFieldUI extends BasicTextUI {
  31. /**
  32. * Creates a UI for a JTextField.
  33. *
  34. * @param c the text field
  35. * @return the UI
  36. */
  37. public static ComponentUI createUI(JComponent c) {
  38. return new BasicTextFieldUI();
  39. }
  40. /**
  41. * Creates a new BasicTextFieldUI.
  42. */
  43. public BasicTextFieldUI() {
  44. super();
  45. }
  46. /**
  47. * Fetches the name used as a key to lookup properties through the
  48. * UIManager. This is used as a prefix to all the standard
  49. * text properties.
  50. *
  51. * @return the name ("TextField")
  52. */
  53. protected String getPropertyPrefix() {
  54. return "TextField";
  55. }
  56. /**
  57. * Creates the caret for a field.
  58. *
  59. * @return the caret
  60. */
  61. protected Caret createCaret() {
  62. return new BasicFieldCaret();
  63. }
  64. /**
  65. * Creates a view (FieldView) based on an element.
  66. *
  67. * @param elem the element
  68. * @return the view
  69. */
  70. public View create(Element elem) {
  71. return new FieldView(elem);
  72. }
  73. /**
  74. * BasicFieldCaret has different scrolling behavior than
  75. * DefaultCaret, selects the field when focus enters it, and
  76. * deselects the field when focus leaves.
  77. */
  78. static class BasicFieldCaret extends DefaultCaret implements UIResource {
  79. public BasicFieldCaret() {
  80. super();
  81. }
  82. }
  83. }