--- /home/cpdev/src/classpath/javax/swing/text/JTextComponent.java	2005-07-14 05:32:46.000000000 +0000
+++ javax/swing/text/JTextComponent.java	2005-06-30 05:35:21.000000000 +0000
@@ -50,12 +50,9 @@
 import java.awt.datatransfer.Transferable;
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.InputMethodListener;
 import java.awt.event.KeyEvent;
 import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
 import java.util.Enumeration;
 import java.util.Hashtable;
 
@@ -71,8 +68,6 @@
 import javax.swing.JViewport;
 import javax.swing.KeyStroke;
 import javax.swing.Scrollable;
-import javax.swing.SwingConstants;
-import javax.swing.Timer;
 import javax.swing.TransferHandler;
 import javax.swing.UIManager;
 import javax.swing.event.CaretEvent;
@@ -302,50 +297,6 @@
   }
 
   /**
-   * The timer that lets the caret blink.
-   */
-  private class CaretBlinkTimer
-    extends Timer
-    implements ActionListener
-  {
-    /**
-     * Creates a new CaretBlinkTimer object with a default delay of 1 second.
-     */
-    public CaretBlinkTimer()
-    {
-      super(1000, null);
-      addActionListener(this);
-    }
-
-    /**
-     * Lets the caret blink.
-     */
-    public void actionPerformed(ActionEvent ev)
-    {
-      Caret c = caret;
-      if (c != null)
-	c.setVisible(!c.isVisible());
-    }
-
-    /**
-     * Updates the blink delay according to the current caret.
-     */
-    public void update()
-    {
-      stop();
-      Caret c = caret;
-      if (c != null)
-	{
-	  setDelay(c.getBlinkRate());
-	  if (editable)
-	    start();
-	  else
-	    c.setVisible(false);
-	}
-    }
-  }
-
-  /**
    * According to <a
    * href="http://java.sun.com/products/jfc/tsc/special_report/kestrel/keybindings.html">this
    * report</a>, a pair of private classes wraps a {@link
@@ -701,9 +652,7 @@
   private Keymap keymap;
   private char focusAccelerator = '\0';
   private NavigationFilter navigationFilter;
-
-  private CaretBlinkTimer caretBlinkTimer;
-
+  
   /**
    * Get a Keymap from the global keymap table, by name.
    *
@@ -934,24 +883,42 @@
     return getUI().getEditorKit(this).getActions();
   }
     
-  // These are package-private to avoid an accessor method.
+  // This is package-private to avoid an accessor method.
   Document doc;
-  Caret caret;
-  boolean editable;
-  
+  private Caret caret;
   private Highlighter highlighter;
   private Color caretColor;
   private Color disabledTextColor;
   private Color selectedTextColor;
   private Color selectionColor;
+  private boolean editable;
   private Insets margin;
   private boolean dragEnabled;
 
+  /** Issues repaint request on document changes. */
+  private DocumentListener repaintListener;
+
   /**
    * Creates a new <code>JTextComponent</code> instance.
    */
   public JTextComponent()
   {
+    repaintListener = new DocumentListener()
+      {
+	public void changedUpdate(DocumentEvent ev)
+	{
+	  repaint();
+	}
+	public void insertUpdate(DocumentEvent ev)
+	{
+	  repaint();
+	}
+	public void removeUpdate(DocumentEvent ev)
+	{
+	  repaint();
+	}
+      };
+
     Keymap defkeymap = getKeymap(DEFAULT_KEYMAP);
     boolean creatingKeymap = false;
     if (defkeymap == null)
@@ -961,10 +928,7 @@
         creatingKeymap = true;
       }
 
-    caretBlinkTimer = new CaretBlinkTimer();
-
     setFocusable(true);
-    setEditable(true);
     enableEvents(AWTEvent.KEY_EVENT_MASK);
     updateUI();
     
@@ -988,6 +952,13 @@
   {
     Document oldDoc = doc;
     doc = newDoc;
+
+    // setup document listener
+    if (oldDoc != null)
+      oldDoc.removeDocumentListener(repaintListener);
+    if (newDoc != null)
+      newDoc.addDocumentListener(repaintListener);
+
     firePropertyChange("document", oldDoc, newDoc);
     revalidate();
     repaint();
@@ -1140,39 +1111,19 @@
 
   public Dimension getPreferredScrollableViewportSize()
   {
-    return getPreferredSize();
+    return null;
   }
 
   public int getScrollableUnitIncrement(Rectangle visible, int orientation,
                                         int direction)
   {
-    // We return 1/10 of the visible area as documented in Sun's API docs.
-    if (orientation == SwingConstants.HORIZONTAL)
-      return visible.width / 10;
-    else if (orientation == SwingConstants.VERTICAL)
-      return visible.height / 10;
-    else
-      throw new IllegalArgumentException("orientation must be either "
-                                      + "javax.swing.SwingConstants.VERTICAL "
-                                      + "or "
-                                      + "javax.swing.SwingConstants.HORIZONTAL"
-                                         );
+    return 0;
   }
 
   public int getScrollableBlockIncrement(Rectangle visible, int orientation,
                                          int direction)
   {
-    // We return the whole visible area as documented in Sun's API docs.
-    if (orientation == SwingConstants.HORIZONTAL)
-      return visible.width;
-    else if (orientation == SwingConstants.VERTICAL)
-      return visible.height;
-    else
-      throw new IllegalArgumentException("orientation must be either "
-                                      + "javax.swing.SwingConstants.VERTICAL "
-                                      + "or "
-                                      + "javax.swing.SwingConstants.HORIZONTAL"
-                                         );
+    return 0;
   }
 
   /**
@@ -1195,14 +1146,6 @@
     if (editable == newValue)
       return;
 
-    if (newValue == true)
-      caretBlinkTimer.start();
-    else
-      {
-        caretBlinkTimer.stop();
-        caret.setVisible(false);
-      }
-
     boolean oldValue = editable;
     editable = newValue;
     firePropertyChange("editable", oldValue, newValue);
@@ -1231,8 +1174,6 @@
     Caret oldCaret = caret;
     caret = newCaret;
 
-    caretBlinkTimer.update();
-
     if (caret != null)
       caret.install(this);
     
@@ -1620,55 +1561,4 @@
   {
     navigationFilter = filter;
   }
-  
-  /**
-   * Read and set the content this component. If not overridden, the
-   * method reads the component content as a plain text.
-   *
-   * The second parameter of this method describes the input stream. It can
-   * be String, URL, File and so on. If not null, this object is added to
-   * the properties of the associated document under the key
-   * {@link Document#StreamDescriptionProperty}.
-   *
-   * @param input an input stream to read from.
-   * @param streamDescription an object, describing the stream.
-   *
-   * @throws IOException if the reader throws it.
-   *
-   * @see getDocument()
-   * @see Document#getProperty(Object)
-   */
-  public void read(Reader input, Object streamDescription)
-            throws IOException
-  {
-    if (streamDescription != null)
-      {
-        Document d = getDocument();
-        if (d != null)
-          d.putProperty(Document.StreamDescriptionProperty, streamDescription);
-      }
-
-    StringBuffer b = new StringBuffer();
-    int c;
-
-    // Read till -1 (EOF).
-    while ((c = input.read()) >= 0)
-      b.append((char) c);
-
-    setText(b.toString());
-  }
-
-  /**
-   * Write the content of this component to the given stream. If not
-   * overridden, the method writes the component content as a plain text.
-   *
-   * @param output the writer to write into.
-   *
-   * @throws IOException if the writer throws it.
-   */
-  public void write(Writer output)
-             throws IOException
-  {
-    output.write(getText());
-  }  
 }
