Index: javax/swing/text/JTextComponent.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/JTextComponent.java,v retrieving revision 1.29 diff -u -r1.29 JTextComponent.java --- javax/swing/text/JTextComponent.java 18 May 2005 08:37:00 -0000 1.29 +++ javax/swing/text/JTextComponent.java 20 May 2005 19:36:49 -0000 @@ -50,6 +50,7 @@ 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; @@ -68,6 +69,7 @@ import javax.swing.JViewport; import javax.swing.KeyStroke; import javax.swing.Scrollable; +import javax.swing.Timer; import javax.swing.TransferHandler; import javax.swing.UIManager; import javax.swing.event.CaretEvent; @@ -297,6 +299,44 @@ } /** + * 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.setVisible(!caret.isVisible()); + } + + /** + * Updates the blink delay according to the current caret. + */ + public void update() + { + stop(); + setDelay(caret.getBlinkRate()); + if (editable) + start(); + else + caret.setVisible(false); + } + } + + /** * According to this * report, a pair of private classes wraps a address@hidden @@ -652,7 +692,9 @@ private Keymap keymap; private char focusAccelerator = '\0'; private NavigationFilter navigationFilter; - + + private CaretBlinkTimer caretBlinkTimer; + /** * Get a Keymap from the global keymap table, by name. * @@ -909,6 +951,8 @@ creatingKeymap = true; } + caretBlinkTimer = new CaretBlinkTimer(); + setFocusable(true); setEditable(true); enableEvents(AWTEvent.KEY_EVENT_MASK); @@ -1121,6 +1165,14 @@ if (editable == newValue) return; + if (newValue == true) + caretBlinkTimer.start(); + else + { + caretBlinkTimer.stop(); + caret.setVisible(false); + } + boolean oldValue = editable; editable = newValue; firePropertyChange("editable", oldValue, newValue); @@ -1149,6 +1201,8 @@ Caret oldCaret = caret; caret = newCaret; + caretBlinkTimer.update(); + if (caret != null) caret.install(this); Index: javax/swing/text/DefaultCaret.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultCaret.java,v retrieving revision 1.9 diff -u -r1.9 DefaultCaret.java --- javax/swing/text/DefaultCaret.java 22 Oct 2004 12:44:01 -0000 1.9 +++ javax/swing/text/DefaultCaret.java 20 May 2005 19:36:49 -0000 @@ -63,7 +63,7 @@ private JTextComponent textComponent; private boolean selectionVisible = true; - private int blinkRate = 0; + private int blinkRate = 500; private int dot = 0; private int mark = 0; private Point magicCaretPosition = null;