jdk/src/share/classes/javax/swing/JFormattedTextField.java

Print this page

        

@@ -25,14 +25,15 @@
 package javax.swing;
 
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.im.InputContext;
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
 import java.io.*;
 import java.text.*;
 import java.util.*;
-import javax.swing.UIManager;
 import javax.swing.event.*;
 import javax.swing.plaf.UIResource;
 import javax.swing.text.*;
 
 /**

@@ -175,10 +176,11 @@
  * has been added to the <code>java.beans</code> package.
  * Please see {@link java.beans.XMLEncoder}.
  *
  * @since 1.4
  */
+@JavaBean
 @SuppressWarnings("serial") // Same-version serialization only
 public class JFormattedTextField extends JTextField {
     private static final String uiClassID = "FormattedTextFieldUI";
     private static final Action[] defaultActions =
             { new CommitAction(), new CancelAction() };

@@ -356,17 +358,17 @@
      * <code>JFormattedTextField.COMMIT_OR_REVERT</code>.
      *
      * @param behavior Identifies behavior when focus is lost
      * @throws IllegalArgumentException if behavior is not one of the known
      *         values
-     * @beaninfo
-     *  enum: COMMIT         JFormattedTextField.COMMIT
-     *        COMMIT_OR_REVERT JFormattedTextField.COMMIT_OR_REVERT
-     *        REVERT         JFormattedTextField.REVERT
-     *        PERSIST        JFormattedTextField.PERSIST
-     *  description: Behavior when component loses focus
      */
+    @BeanProperty(bound = false, enumerationValues = {
+            "JFormattedTextField.COMMIT",
+            "JFormattedTextField.COMMIT_OR_REVERT",
+            "JFormattedTextField.REVERT",
+            "JFormattedTextField.PERSIST"}, description
+            = "Behavior when component loses focus")
     public void setFocusLostBehavior(int behavior) {
         if (behavior != COMMIT && behavior != COMMIT_OR_REVERT &&
             behavior != PERSIST && behavior != REVERT) {
             throw new IllegalArgumentException("setFocusLostBehavior must be one of: JFormattedTextField.COMMIT, JFormattedTextField.COMMIT_OR_REVERT, JFormattedTextField.PERSIST or JFormattedTextField.REVERT");
         }

@@ -406,16 +408,13 @@
      * <p>
      * This is a JavaBeans bound property.
      *
      * @param tf <code>AbstractFormatterFactory</code> used to lookup
      *          instances of <code>AbstractFormatter</code>
-     * @beaninfo
-     *       bound: true
-     *   attribute: visualUpdate true
-     * description: AbstractFormatterFactory, responsible for returning an
-     *              AbstractFormatter that can format the current value.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "AbstractFormatterFactory, responsible for returning an AbstractFormatter that can format the current value.")
     public void setFormatterFactory(AbstractFormatterFactory tf) {
         AbstractFormatterFactory oldFactory = factory;
 
         factory = tf;
         firePropertyChange("formatterFactory", oldFactory, tf);

@@ -447,14 +446,10 @@
      * <p>
      * This is a JavaBeans bound property.
      *
      * @see #setFormatterFactory
      * @param format AbstractFormatter to use for formatting
-     * @beaninfo
-     *       bound: true
-     *   attribute: visualUpdate true
-     * description: TextFormatter, responsible for formatting the current value
      */
     protected void setFormatter(AbstractFormatter format) {
         AbstractFormatter oldFormat = this.format;
 
         if (oldFormat != null) {

@@ -473,10 +468,12 @@
      * Returns the <code>AbstractFormatter</code> that is used to format and
      * parse the current value.
      *
      * @return AbstractFormatter used for formatting
      */
+    @BeanProperty(visualUpdate = true, description
+            = "TextFormatter, responsible for formatting the current value")
     public AbstractFormatter getFormatter() {
         return format;
     }
 
     /**

@@ -489,15 +486,13 @@
      * The default value of this property is null.
      * <p>
      * This is a JavaBeans bound property.
      *
      * @param value Current value to display
-     * @beaninfo
-     *       bound: true
-     *   attribute: visualUpdate true
-     * description: The value to be formatted.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "The value to be formatted.")
     public void setValue(Object value) {
         if (value != null && getFormatterFactory() == null) {
             setFormatterFactory(getDefaultFormatterFactory(value));
         }
         setValue(value, true, true);

@@ -543,15 +538,13 @@
      * Based on the look and feel this may visually change the state of
      * the receiver.
      *
      * @param isValid boolean indicating if the currently edited value is
      *        valid.
-     * @beaninfo
-     *       bound: true
-     *   attribute: visualUpdate true
-     * description: True indicates the edited value is valid
      */
+    @BeanProperty(visualUpdate = true, description
+            = "True indicates the edited value is valid")
     private void setEditValid(boolean isValid) {
         if (isValid != editValid) {
             editValid = isValid;
             firePropertyChange("editValid", Boolean.valueOf(!isValid),
                                Boolean.valueOf(isValid));

@@ -563,10 +556,11 @@
      * this is managed by the current <code>AbstractFormatter</code>, as such
      * there is no public setter for it.
      *
      * @return true if the current value being edited is valid.
      */
+    @BeanProperty(bound = false)
     public boolean isEditValid() {
         return editValid;
     }
 
     /**

@@ -672,20 +666,22 @@
      * editor itself supports.  These are useful for binding
      * to events, such as in a keymap.
      *
      * @return the command list
      */
+    @BeanProperty(bound = false)
     public Action[] getActions() {
         return TextAction.augmentList(super.getActions(), defaultActions);
     }
 
     /**
      * Gets the class ID for a UI.
      *
      * @return the string "FormattedTextFieldUI"
      * @see JComponent#getUIClassID
      */
+    @BeanProperty(bound = false)
     public String getUIClassID() {
         return uiClassID;
     }
 
     /**

@@ -694,15 +690,13 @@
      * the document, which gets displayed by the editor after revalidation.
      * A PropertyChange event ("document") is propagated to each listener.
      *
      * @param doc  the document to display/edit
      * @see #getDocument
-     * @beaninfo
-     *  description: the text document model
-     *        bound: true
-     *       expert: true
      */
+    @BeanProperty(expert = true, description
+            = "the text document model")
     public void setDocument(Document doc) {
         if (documentListener != null && getDocument() != null) {
             getDocument().removeDocumentListener(documentListener);
         }
         super.setDocument(doc);