jdk/src/share/classes/javax/swing/text/JTextComponent.java

Print this page

        

@@ -27,10 +27,12 @@
 import com.sun.beans.util.Cache;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
 import java.beans.Transient;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Enumeration;
 import java.util.Vector;

@@ -65,11 +67,10 @@
 
 import javax.print.attribute.*;
 
 import sun.awt.AppContext;
 
-
 import sun.swing.PrintingStatus;
 import sun.swing.SwingUtilities2;
 import sun.swing.text.TextComponentPrintable;
 import sun.swing.SwingAccessor;
 

@@ -273,13 +274,10 @@
  * the same version of Swing.  As of 1.4, support for long term storage
  * of all JavaBeans™
  * has been added to the <code>java.beans</code> package.
  * Please see {@link java.beans.XMLEncoder}.
  *
- * @beaninfo
- *     attribute: isContainer false
- *
  * @author  Timothy Prinzing
  * @author Igor Kushnirskiy (printing support)
  * @see Document
  * @see DocumentEvent
  * @see DocumentListener

@@ -288,10 +286,12 @@
  * @see CaretListener
  * @see TextUI
  * @see View
  * @see ViewFactory
  */
+@JavaBean(defaultProperty = "UI")
+@SwingContainer(false)
 @SuppressWarnings("serial") // Same-version serialization only
 public abstract class JTextComponent extends JComponent implements Scrollable, Accessible
 {
     /**
      * Creates a new <code>JTextComponent</code>.

@@ -372,10 +372,11 @@
      * @see #addCaretListener
      * @see #removeCaretListener
      *
      * @since 1.4
      */
+    @BeanProperty(bound = false)
     public CaretListener[] getCaretListeners() {
         return listenerList.getListeners(CaretListener.class);
     }
 
     /**

@@ -406,15 +407,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) {
         Document old = model;
 
         /*
          * acquire a read lock on the old model to prevent notification of

@@ -493,10 +492,11 @@
      * 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 getUI().getEditorKit(this).getActions();
     }
 
     /**

@@ -508,14 +508,13 @@
      * appropriate margin space (else this property will effectively
      * be ignored).  This causes a redraw of the component.
      * A PropertyChange event ("margin") is sent to all listeners.
      *
      * @param m the space between the border and the text
-     * @beaninfo
-     *  description: desired space between the border and text area
-     *        bound: true
      */
+    @BeanProperty(description
+            = "desired space between the border and text area")
     public void setMargin(Insets m) {
         Insets old = margin;
         margin = m;
         firePropertyChange("margin", old, m);
         invalidate();

@@ -572,15 +571,13 @@
      * a custom caret if desired.  Setting the caret results in a
      * PropertyChange event ("caret") being fired.
      *
      * @param c the caret
      * @see #getCaret
-     * @beaninfo
-     *  description: the caret used to select/navigate
-     *        bound: true
-     *       expert: true
      */
+    @BeanProperty(expert = true, description
+            = "the caret used to select/navigate")
     public void setCaret(Caret c) {
         if (caret != null) {
             caret.removeChangeListener(caretEvent);
             caret.deinstall(this);
         }

@@ -610,15 +607,13 @@
      * A PropertyChange event ("highlighter") is fired
      * when a new highlighter is installed.
      *
      * @param h the highlighter
      * @see #getHighlighter
-     * @beaninfo
-     *  description: object responsible for background highlights
-     *        bound: true
-     *       expert: true
      */
+    @BeanProperty(expert = true, description
+            = "object responsible for background highlights")
     public void setHighlighter(Highlighter h) {
         if (highlighter != null) {
             highlighter.deinstall(this);
         }
         Highlighter old = highlighter;

@@ -636,14 +631,13 @@
      * A PropertyChange event ("keymap") is fired when a new keymap
      * is installed.
      *
      * @param map the keymap
      * @see #getKeymap
-     * @beaninfo
-     *  description: set of key event to action bindings to use
-     *        bound: true
      */
+    @BeanProperty(description
+            = "set of key event to action bindings to use")
     public void setKeymap(Keymap map) {
         Keymap old = keymap;
         keymap = map;
         firePropertyChange("keymap", old, keymap);
         updateInputMap(old, map);

@@ -675,15 +669,13 @@
      * @see java.awt.GraphicsEnvironment#isHeadless
      * @see #getDragEnabled
      * @see #setTransferHandler
      * @see TransferHandler
      * @since 1.4
-     *
-     * @beaninfo
-     *  description: determines whether automatic drag handling is enabled
-     *        bound: false
      */
+    @BeanProperty(bound = false, description
+            = "determines whether automatic drag handling is enabled")
     public void setDragEnabled(boolean b) {
         checkDragEnabled(b);
         dragEnabled = b;
     }
 

@@ -951,10 +943,11 @@
      * @return the drop location
      * @see #setDropMode
      * @see TransferHandler#canImport(TransferHandler.TransferSupport)
      * @since 1.6
      */
+    @BeanProperty(bound = false)
     public final DropLocation getDropLocation() {
         return dropLocation;
     }
 
 

@@ -1216,15 +1209,13 @@
      * Setting the color results in a PropertyChange event ("caretColor")
      * being fired.
      *
      * @param c the color
      * @see #getCaretColor
-     * @beaninfo
-     *  description: the color used to render the caret
-     *        bound: true
-     *    preferred: true
      */
+    @BeanProperty(preferred = true, description
+            = "the color used to render the caret")
     public void setCaretColor(Color c) {
         Color old = caretColor;
         caretColor = c;
         firePropertyChange("caretColor", old, caretColor);
     }

@@ -1245,15 +1236,13 @@
      * <code>Color.white</code>.  Setting the color results in a
      * PropertyChange event ("selectionColor").
      *
      * @param c the color
      * @see #getSelectionColor
-     * @beaninfo
-     *  description: color used to render selection background
-     *        bound: true
-     *    preferred: true
      */
+    @BeanProperty(preferred = true, description
+            = "color used to render selection background")
     public void setSelectionColor(Color c) {
         Color old = selectionColor;
         selectionColor = c;
         firePropertyChange("selectionColor", old, selectionColor);
     }

@@ -1274,15 +1263,13 @@
      * <code>Color.black</code>. Setting the color results in a
      * PropertyChange event ("selectedTextColor") being fired.
      *
      * @param c the color
      * @see #getSelectedTextColor
-     * @beaninfo
-     *  description: color used to render selected text
-     *        bound: true
-     *    preferred: true
      */
+    @BeanProperty(preferred = true, description
+            = "color used to render selected text")
     public void setSelectedTextColor(Color c) {
         Color old = selectedTextColor;
         selectedTextColor = c;
         firePropertyChange("selectedTextColor", old, selectedTextColor);
     }

@@ -1302,15 +1289,13 @@
      * disabled text.  Setting the color fires off a
      * PropertyChange event ("disabledTextColor").
      *
      * @param c the color
      * @see #getDisabledTextColor
-     * @beaninfo
-     *  description: color used to render disabled text
-     *        bound: true
-     *    preferred: true
      */
+    @BeanProperty(preferred = true, description
+            = "color used to render disabled text")
     public void setDisabledTextColor(Color c) {
         Color old = disabledTextColor;
         disabledTextColor = c;
         firePropertyChange("disabledTextColor", old, disabledTextColor);
     }

@@ -1531,14 +1516,13 @@
      * effect of turning off the focus accelerator.  When the new key
      * is set, a PropertyChange event (FOCUS_ACCELERATOR_KEY) will be fired.
      *
      * @param aKey the key
      * @see #getFocusAccelerator
-     * @beaninfo
-     *  description: accelerator character used to grab focus
-     *        bound: true
      */
+    @BeanProperty(description
+            = "accelerator character used to grab focus")
     public void setFocusAccelerator(char aKey) {
         aKey = Character.toUpperCase(aKey);
         char old = focusAccelerator;
         focusAccelerator = aKey;
         // Fix for 4341002: value of FOCUS_ACCELERATOR_KEY is wrong.

@@ -1628,13 +1612,13 @@
      *
      * @param position the position
      * @exception    IllegalArgumentException if the value supplied
      *               for <code>position</code> is less than zero or greater
      *               than the component's text length
-     * @beaninfo
-     * description: the caret position
      */
+    @BeanProperty(bound = false, description
+            = "the caret position")
     public void setCaretPosition(int position) {
         Document doc = getDocument();
         if (doc != null) {
             if (position > doc.getLength() || position < 0) {
                 throw new IllegalArgumentException("bad position: " + position);

@@ -1668,13 +1652,13 @@
      * use <code>DocumentListener</code>.
      *
      * @param t the new text to be set
      * @see #getText
      * @see DefaultCaret
-     * @beaninfo
-     * description: the text of this component
      */
+    @BeanProperty(bound = false, description
+            = "the text of this component")
     public void setText(String t) {
         try {
             Document doc = getDocument();
             if (doc instanceof AbstractDocument) {
                 ((AbstractDocument)doc).replace(0, doc.getLength(), t,null);

@@ -1720,10 +1704,11 @@
      * @return the text
      * @exception IllegalArgumentException if the selection doesn't
      *  have a valid mapping into the document for some reason
      * @see #setText
      */
+    @BeanProperty(bound = false)
     public String getSelectedText() {
         String txt = null;
         int p0 = Math.min(caret.getDot(), caret.getMark());
         int p1 = Math.max(caret.getDot(), caret.getMark());
         if (p0 != p1) {

@@ -1754,14 +1739,13 @@
      * A PropertyChange event ("editable") is fired when the
      * state is changed.
      *
      * @param b the boolean to be set
      * @see #isEditable
-     * @beaninfo
-     * description: specifies if the text can be edited
-     *       bound: true
      */
+    @BeanProperty(description
+            = "specifies if the text can be edited")
     public void setEditable(boolean b) {
         if (b != editable) {
             boolean oldVal = editable;
             editable = b;
             enableInputMethods(editable);

@@ -1791,13 +1775,13 @@
      * that called this method on <code>java.awt.TextComponent</code>.
      * This is implemented to forward to the <code>Caret</code>
      * implementation which is where the actual selection is maintained.
      *
      * @param selectionStart the start position of the text &ge; 0
-     * @beaninfo
-     * description: starting location of the selection.
      */
+    @BeanProperty(bound = false, description
+            = "starting location of the selection.")
     public void setSelectionStart(int selectionStart) {
         /* Route through select method to enforce consistent policy
          * between selectionStart and selectionEnd.
          */
         select(selectionStart, getSelectionEnd());

@@ -1824,13 +1808,13 @@
      * that called this method on <code>java.awt.TextComponent</code>.
      * This is implemented to forward to the <code>Caret</code>
      * implementation which is where the actual selection is maintained.
      *
      * @param selectionEnd the end position of the text &ge; 0
-     * @beaninfo
-     * description: ending location of the selection.
      */
+    @BeanProperty(bound = false, description
+            = "ending location of the selection.")
     public void setSelectionEnd(int selectionEnd) {
         /* Route through select method to enforce consistent policy
          * between selectionStart and selectionEnd.
          */
         select(getSelectionStart(), selectionEnd);

@@ -1942,10 +1926,11 @@
      * the preferred size of the component.
      *
      * @return the <code>preferredSize</code> of a <code>JViewport</code>
      * whose view is this <code>Scrollable</code>
      */
+    @BeanProperty(bound = false)
     public Dimension getPreferredScrollableViewportSize() {
         return getPreferredSize();
     }
 
 

@@ -2025,10 +2010,11 @@
      * will use this method each time they are validated.
      *
      * @return true if a viewport should force the <code>Scrollable</code>s
      *   width to match its own
      */
+    @BeanProperty(bound = false)
     public boolean getScrollableTracksViewportWidth() {
         Container parent = SwingUtilities.getUnwrappedParent(this);
         if (parent instanceof JViewport) {
             return parent.getWidth() > getPreferredSize().width;
         }

@@ -2046,10 +2032,11 @@
      * will use this method each time they are validated.
      *
      * @return true if a viewport should force the Scrollables height
      *   to match its own
      */
+    @BeanProperty(bound = false)
     public boolean getScrollableTracksViewportHeight() {
         Container parent = SwingUtilities.getUnwrappedParent(this);
         if (parent instanceof JViewport) {
             return parent.getHeight() > getPreferredSize().height;
         }

@@ -2480,10 +2467,11 @@
      *
      * @return an <code>AccessibleJTextComponent</code> that serves as the
      *         <code>AccessibleContext</code> of this
      *         <code>JTextComponent</code>
      */
+    @BeanProperty(bound = false)
     public AccessibleContext getAccessibleContext() {
         if (accessibleContext == null) {
             accessibleContext = new AccessibleJTextComponent();
         }
         return accessibleContext;

@@ -4535,10 +4523,11 @@
     }
 
     //
     // Overrides this method to become an active input method client.
     //
+    @BeanProperty(bound = false)
     public InputMethodRequests getInputMethodRequests() {
         if (inputMethodRequestsHandler == null) {
             inputMethodRequestsHandler = new InputMethodRequestsHandler();
             Document doc = getDocument();
             if (doc != null) {