Skip to content

Commit 73a47f0

Browse files
committed
4622866: javax.swing.text.Document.remove(int, int) has a misleading picture
Reviewed-by: prr
1 parent cfcbfc6 commit 73a47f0

File tree

3 files changed

+170
-11
lines changed

3 files changed

+170
-11
lines changed

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

+17-11
Original file line numberDiff line numberDiff line change
@@ -423,33 +423,39 @@ public interface Document {
423423

424424
/**
425425
* Removes a portion of the content of the document.
426-
* This will cause a DocumentEvent of type
427-
* DocumentEvent.EventType.REMOVE to be sent to the
428-
* registered DocumentListeners, unless an exception
426+
* This will cause a {@code DocumentEvent} of type
427+
* {@code DocumentEvent.EventType.REMOVE} to be sent to the
428+
* registered {@code DocumentListener}s, unless an exception
429429
* is thrown. The notification will be sent to the
430-
* listeners by calling the removeUpdate method on the
431-
* DocumentListeners.
430+
* listeners by calling the {@code removeUpdate} method on the
431+
* {@code DocumentListener}.
432432
* <p>
433433
* To ensure reasonable behavior in the face
434434
* of concurrency, the event is dispatched after the
435435
* mutation has occurred. This means that by the time a
436436
* notification of removal is dispatched, the document
437437
* has already been updated and any marks created by
438-
* <code>createPosition</code> have already changed.
438+
* {@code createPosition} have already changed.
439439
* For a removal, the end of the removal range is collapsed
440440
* down to the start of the range, and any marks in the removal
441441
* range are collapsed down to the start of the range.
442-
* <p style="text-align:center"><img src="doc-files/Document-remove.gif"
442+
* <p>
443+
* For example, if the document contains the text
444+
* <i>&lsquo;The quick brown fox&rsquo;</i>,
445+
* calling {@code remove(4, 6)} will remove the word
446+
* <i>&lsquo;quick&rsquo;</i> and the following space from the text,
447+
* and all the marks in the range 4&ndash;10 will be collapsed to 4.
448+
* <p style="text-align:center"><img src="doc-files/Document-remove.svg"
443449
* alt="Diagram shows removal of 'quick' from 'The quick brown fox.'">
444450
* <p>
445-
* If the Document structure changed as result of the removal,
446-
* the details of what Elements were inserted and removed in
451+
* If the document structure changed as result of the removal,
452+
* the details of what {@code Element}s were inserted and removed in
447453
* response to the change will also be contained in the generated
448-
* DocumentEvent. It is up to the implementation of a Document
454+
* {@code DocumentEvent}. It is up to the implementation of a {@code Document}
449455
* to decide how the structure should change in response to a
450456
* remove.
451457
* <p>
452-
* If the Document supports undo/redo, an UndoableEditEvent will
458+
* If the {@code Document} supports undo/redo, an {@code UndoableEditEvent} will
453459
* also be generated.
454460
*
455461
* @param offs the offset from the beginning &gt;= 0
Binary file not shown.
Loading

0 commit comments

Comments
 (0)