< prev index next >

src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java

Print this page

        

*** 47,59 **** * The timer thread fires asynchronously, and causes the caret to simply * repaint the most recent bounding box. The caret also tracks change * as the document is modified. Typically this will happen on the * event dispatch thread as a result of some mouse or keyboard event. * The caret behavior on both synchronous and asynchronous documents updates ! * is controlled by <code>UpdatePolicy</code> property. The repaint of the * new caret location will occur on the event thread in any case, as calls to ! * <code>modelToView</code> are only safe on the event thread. * <p> * The caret acts as a mouse and focus listener on the text component * it has been installed in, and defines the caret semantics based upon * those events. The listener methods can be reimplemented to change the * semantics. --- 47,59 ---- * The timer thread fires asynchronously, and causes the caret to simply * repaint the most recent bounding box. The caret also tracks change * as the document is modified. Typically this will happen on the * event dispatch thread as a result of some mouse or keyboard event. * The caret behavior on both synchronous and asynchronous documents updates ! * is controlled by {@code UpdatePolicy} property. The repaint of the * new caret location will occur on the event thread in any case, as calls to ! * {@code modelToView} are only safe on the event thread. * <p> * The caret acts as a mouse and focus listener on the text component * it has been installed in, and defines the caret semantics based upon * those events. The listener methods can be reimplemented to change the * semantics.
*** 66,76 **** * The Highlighter bound to the associated text component is used to * render the selection by default. * Selection appearance can be customized by supplying a * painter to use for the highlights. By default a painter is used that * will render a solid color as specified in the associated text component ! * in the <code>SelectionColor</code> property. This can easily be changed * by reimplementing the * {@link #getSelectionPainter getSelectionPainter} * method. * <p> * A customized caret appearance can be achieved by reimplementing --- 66,76 ---- * The Highlighter bound to the associated text component is used to * render the selection by default. * Selection appearance can be customized by supplying a * painter to use for the highlights. By default a painter is used that * will render a solid color as specified in the associated text component ! * in the {@code SelectionColor} property. This can easily be changed * by reimplementing the * {@link #getSelectionPainter getSelectionPainter} * method. * <p> * A customized caret appearance can be achieved by reimplementing
*** 97,107 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @author Timothy Prinzing * @see Caret */ --- 97,107 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @author Timothy Prinzing * @see Caret */
*** 156,197 **** * means here the position relative to the start of the document. * For example if * a character is typed within editable text component it is inserted * at the caret position and the caret moves to the next absolute * position within the document due to insertion and if ! * <code>BACKSPACE</code> is typed then caret decreases its absolute * position due to removal of a character before it. Sometimes * it may be useful to turn off the caret position updates so that * the caret stays at the same absolute position within the * document position regardless of any document updates. * <p> * The following update policies are allowed: * <ul> ! * <li><code>NEVER_UPDATE</code>: the caret stays at the same * absolute position in the document regardless of any document * updates, except when document length becomes less than * the current caret position due to removal. In that case caret * position is adjusted to the end of the document. * The caret doesn't try to keep itself visible by scrolling * the associated view when using this policy. </li> ! * <li><code>ALWAYS_UPDATE</code>: the caret always tracks document * changes. For regular changes it increases its position * if an insertion occurs before or at its current position, * and decreases position if a removal occurs before * its current position. For undo/redo updates it is always * moved to the position where update occurred. The caret * also tries to keep itself visible by calling ! * <code>adjustVisibility</code> method.</li> ! * <li><code>UPDATE_WHEN_ON_EDT</code>: acts like <code>ALWAYS_UPDATE</code> * if the document updates are performed on the Event Dispatching Thread ! * and like <code>NEVER_UPDATE</code> if updates are performed on * other thread. </li> * </ul> <p> ! * The default property value is <code>UPDATE_WHEN_ON_EDT</code>. * ! * @param policy one of the following values : <code>UPDATE_WHEN_ON_EDT</code>, ! * <code>NEVER_UPDATE</code>, <code>ALWAYS_UPDATE</code> * @throws IllegalArgumentException if invalid value is passed * * @see #getUpdatePolicy * @see #adjustVisibility * @see #UPDATE_WHEN_ON_EDT --- 156,197 ---- * means here the position relative to the start of the document. * For example if * a character is typed within editable text component it is inserted * at the caret position and the caret moves to the next absolute * position within the document due to insertion and if ! * {@code BACKSPACE} is typed then caret decreases its absolute * position due to removal of a character before it. Sometimes * it may be useful to turn off the caret position updates so that * the caret stays at the same absolute position within the * document position regardless of any document updates. * <p> * The following update policies are allowed: * <ul> ! * <li>{@code NEVER_UPDATE}: the caret stays at the same * absolute position in the document regardless of any document * updates, except when document length becomes less than * the current caret position due to removal. In that case caret * position is adjusted to the end of the document. * The caret doesn't try to keep itself visible by scrolling * the associated view when using this policy. </li> ! * <li>{@code ALWAYS_UPDATE}: the caret always tracks document * changes. For regular changes it increases its position * if an insertion occurs before or at its current position, * and decreases position if a removal occurs before * its current position. For undo/redo updates it is always * moved to the position where update occurred. The caret * also tries to keep itself visible by calling ! * {@code adjustVisibility} method.</li> ! * <li>{@code UPDATE_WHEN_ON_EDT}: acts like {@code ALWAYS_UPDATE} * if the document updates are performed on the Event Dispatching Thread ! * and like {@code NEVER_UPDATE} if updates are performed on * other thread. </li> * </ul> <p> ! * The default property value is {@code UPDATE_WHEN_ON_EDT}. * ! * @param policy one of the following values : {@code UPDATE_WHEN_ON_EDT}, ! * {@code NEVER_UPDATE}, {@code ALWAYS_UPDATE} * @throws IllegalArgumentException if invalid value is passed * * @see #getUpdatePolicy * @see #adjustVisibility * @see #UPDATE_WHEN_ON_EDT
*** 205,216 **** } /** * Gets the caret movement policy on document updates. * ! * @return one of the following values : <code>UPDATE_WHEN_ON_EDT</code>, ! * <code>NEVER_UPDATE</code>, <code>ALWAYS_UPDATE</code> * * @see #setUpdatePolicy * @see #UPDATE_WHEN_ON_EDT * @see #NEVER_UPDATE * @see #ALWAYS_UPDATE --- 205,216 ---- } /** * Gets the caret movement policy on document updates. * ! * @return one of the following values : {@code UPDATE_WHEN_ON_EDT}, ! * {@code NEVER_UPDATE}, {@code ALWAYS_UPDATE} * * @see #setUpdatePolicy * @see #UPDATE_WHEN_ON_EDT * @see #NEVER_UPDATE * @see #ALWAYS_UPDATE
*** 767,777 **** /** * Returns an array of all the change listeners * registered on this caret. * ! * @return all of this caret's <code>ChangeListener</code>s * or an empty * array if no change listeners are currently registered * * @see #addChangeListener * @see #removeChangeListener --- 767,777 ---- /** * Returns an array of all the change listeners * registered on this caret. * ! * @return all of this caret's {@code ChangeListener}s * or an empty * array if no change listeners are currently registered * * @see #addChangeListener * @see #removeChangeListener
*** 812,827 **** * <code><em>Foo</em>Listener</code>s are registered using the * <code>add<em>Foo</em>Listener</code> method. * * <p> * ! * You can specify the <code>listenerType</code> argument * with a class literal, * such as * <code><em>Foo</em>Listener.class</code>. * For example, you can query a ! * <code>DefaultCaret</code> <code>c</code> * for its change listeners with the following code: * * <pre>ChangeListener[] cls = (ChangeListener[])(c.getListeners(ChangeListener.class));</pre> * * If no such listeners exist, this method returns an empty array. --- 812,827 ---- * <code><em>Foo</em>Listener</code>s are registered using the * <code>add<em>Foo</em>Listener</code> method. * * <p> * ! * You can specify the {@code listenerType} argument * with a class literal, * such as * <code><em>Foo</em>Listener.class</code>. * For example, you can query a ! * {@code DefaultCaret c} * for its change listeners with the following code: * * <pre>ChangeListener[] cls = (ChangeListener[])(c.getListeners(ChangeListener.class));</pre> * * If no such listeners exist, this method returns an empty array.
*** 829,841 **** * @param listenerType the type of listeners requested * @return an array of all objects registered as * <code><em>Foo</em>Listener</code>s on this component, * or an empty array if no such * listeners have been added ! * @exception ClassCastException if <code>listenerType</code> * doesn't specify a class or interface that implements ! * <code>java.util.EventListener</code> * * @see #getChangeListeners * * @since 1.3 */ --- 829,841 ---- * @param listenerType the type of listeners requested * @return an array of all objects registered as * <code><em>Foo</em>Listener</code>s on this component, * or an empty array if no such * listeners have been added ! * @exception ClassCastException if {@code listenerType} * doesn't specify a class or interface that implements ! * {@code java.util.EventListener} * * @see #getChangeListeners * * @since 1.3 */
*** 887,903 **** } /** * Determines if the caret is currently active. * <p> ! * This method returns whether or not the <code>Caret</code> * is currently in a blinking state. It does not provide * information as to whether it is currently blinked on or off. * To determine if the caret is currently painted use the ! * <code>isVisible</code> method. * ! * @return <code>true</code> if active else <code>false</code> * @see #isVisible * * @since 1.5 */ public boolean isActive() { --- 887,903 ---- } /** * Determines if the caret is currently active. * <p> ! * This method returns whether or not the {@code Caret} * is currently in a blinking state. It does not provide * information as to whether it is currently blinked on or off. * To determine if the caret is currently painted use the ! * {@code isVisible} method. * ! * @return {@code true} if active else {@code false} * @see #isVisible * * @since 1.5 */ public boolean isActive() {
*** 906,918 **** /** * Indicates whether or not the caret is currently visible. As the * caret flashes on and off the return value of this will change * between true, when the caret is painted, and false, when the ! * caret is not painted. <code>isActive</code> indicates whether * or not the caret is in a blinking state, such that it <b>can</b> ! * be visible, and <code>isVisible</code> indicates whether or not * the caret <b>is</b> actually visible. * <p> * Subclasses that wish to render a different flashing caret * should override paint and only paint the caret if this method * returns true. --- 906,918 ---- /** * Indicates whether or not the caret is currently visible. As the * caret flashes on and off the return value of this will change * between true, when the caret is painted, and false, when the ! * caret is not painted. {@code isActive} indicates whether * or not the caret is in a blinking state, such that it <b>can</b> ! * be visible, and {@code isVisible} indicates whether or not * the caret <b>is</b> actually visible. * <p> * Subclasses that wish to render a different flashing caret * should override paint and only paint the caret if this method * returns true.
*** 926,957 **** } /** * Sets the caret visibility, and repaints the caret. * It is important to understand the relationship between this method, ! * <code>isVisible</code> and <code>isActive</code>. ! * Calling this method with a value of <code>true</code> activates the ! * caret blinking. Setting it to <code>false</code> turns it completely off. * To determine whether the blinking is active, you should call ! * <code>isActive</code>. In effect, <code>isActive</code> is an * appropriate corresponding "getter" method for this one. ! * <code>isVisible</code> can be used to fetch the current * visibility status of the caret, meaning whether or not it is currently * painted. This status will change as the caret blinks on and off. * <p> * Here's a list showing the potential return values of both ! * <code>isActive</code> and <code>isVisible</code> * after calling this method: * <p> ! * <b><code>setVisible(true)</code></b>: * <ul> * <li>isActive(): true</li> * <li>isVisible(): true or false depending on whether * or not the caret is blinked on or off</li> * </ul> * <p> ! * <b><code>setVisible(false)</code></b>: * <ul> * <li>isActive(): false</li> * <li>isVisible(): false</li> * </ul> * --- 926,957 ---- } /** * Sets the caret visibility, and repaints the caret. * It is important to understand the relationship between this method, ! * {@code isVisible} and {@code isActive}. ! * Calling this method with a value of {@code true} activates the ! * caret blinking. Setting it to {@code false} turns it completely off. * To determine whether the blinking is active, you should call ! * {@code isActive}. In effect, {@code isActive} is an * appropriate corresponding "getter" method for this one. ! * {@code isVisible} can be used to fetch the current * visibility status of the caret, meaning whether or not it is currently * painted. This status will change as the caret blinks on and off. * <p> * Here's a list showing the potential return values of both ! * {@code isActive} and {@code isVisible} * after calling this method: * <p> ! * <b>{@code setVisible(true)}</b>: * <ul> * <li>isActive(): true</li> * <li>isVisible(): true or false depending on whether * or not the caret is blinked on or off</li> * </ul> * <p> ! * <b>{@code setVisible(false)}</b>: * <ul> * <li>isActive(): false</li> * <li>isVisible(): false</li> * </ul> *
*** 1069,1080 **** /** * Moves the caret position to the specified position, with the * specified bias. * * @param dot the position &gt;= 0 ! * @param dotBias the bias for this position, not <code>null</code> ! * @throws IllegalArgumentException if the bias is <code>null</code> * @see Caret#moveDot * @since 1.6 */ public void moveDot(int dot, Position.Bias dotBias) { if (dotBias == null) { --- 1069,1080 ---- /** * Moves the caret position to the specified position, with the * specified bias. * * @param dot the position &gt;= 0 ! * @param dotBias the bias for this position, not {@code null} ! * @throws IllegalArgumentException if the bias is {@code null} * @see Caret#moveDot * @since 1.6 */ public void moveDot(int dot, Position.Bias dotBias) { if (dotBias == null) {
*** 1136,1147 **** * Sets the caret position and mark to the specified position, with the * specified bias. This implicitly sets the selection range * to zero. * * @param dot the position &gt;= 0 ! * @param dotBias the bias for this position, not <code>null</code> ! * @throws IllegalArgumentException if the bias is <code>null</code> * @see Caret#setDot * @since 1.6 */ public void setDot(int dot, Position.Bias dotBias) { if (dotBias == null) { --- 1136,1147 ---- * Sets the caret position and mark to the specified position, with the * specified bias. This implicitly sets the selection range * to zero. * * @param dot the position &gt;= 0 ! * @param dotBias the bias for this position, not {@code null} ! * @throws IllegalArgumentException if the bias is {@code null} * @see Caret#setDot * @since 1.6 */ public void setDot(int dot, Position.Bias dotBias) { if (dotBias == null) {
*** 1296,1306 **** } /** * Repaints the new caret position, with the * assumption that this is happening on the ! * event thread so that calling <code>modelToView</code> * is safe. */ void repaintNewCaret() { if (component != null) { TextUI mapper = component.getUI(); --- 1296,1306 ---- } /** * Repaints the new caret position, with the * assumption that this is happening on the ! * event thread so that calling {@code modelToView} * is safe. */ void repaintNewCaret() { if (component != null) { TextUI mapper = component.getUI();
*** 1383,1393 **** return handler; } /** * This is invoked after the document changes to verify the current ! * dot/mark is valid. We do this in case the <code>NavigationFilter</code> * changed where to position the dot, that resulted in the current location * being bogus. */ private void ensureValidPosition() { int length = component.getDocument().getLength(); --- 1383,1393 ---- return handler; } /** * This is invoked after the document changes to verify the current ! * dot/mark is valid. We do this in case the {@code NavigationFilter} * changed where to position the dot, that resulted in the current location * being bogus. */ private void ensureValidPosition() { int length = component.getDocument().getLength();
*** 1427,1438 **** * The superclass behavior of comparing rectangles * is not desired, so this is changed to the Object * behavior. * * @param obj the object to compare this font with ! * @return <code>true</code> if the objects are equal; ! * <code>false</code> otherwise */ public boolean equals(Object obj) { return (this == obj); } --- 1427,1438 ---- * The superclass behavior of comparing rectangles * is not desired, so this is changed to the Object * behavior. * * @param obj the object to compare this font with ! * @return {@code true} if the objects are equal; ! * {@code false} otherwise */ public boolean equals(Object obj) { return (this == obj); }
< prev index next >