Skip to content

Commit caf053b

Browse files
committed
8337287: Update image in javax.swing.text.Document.insert
Reviewed-by: serb, prr, abhiscxk
1 parent 8647c00 commit caf053b

File tree

3 files changed

+171
-14
lines changed

3 files changed

+171
-14
lines changed

Diff for: src/java.desktop/share/classes/javax/swing/text/Document.java

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -471,32 +471,39 @@ public interface Document {
471471
public void remove(int offs, int len) throws BadLocationException;
472472

473473
/**
474-
* Inserts a string of content. This will cause a DocumentEvent
475-
* of type DocumentEvent.EventType.INSERT to be sent to the
476-
* registered DocumentListeners, unless an exception is thrown.
477-
* The DocumentEvent will be delivered by calling the
478-
* insertUpdate method on the DocumentListener.
479-
* The offset and length of the generated DocumentEvent
480-
* will indicate what change was actually made to the Document.
481-
* <p style="text-align:center"><img src="doc-files/Document-insert.gif"
474+
* Inserts a string of content. This will cause a {@code DocumentEvent}
475+
* of type {@code DocumentEvent.EventType.INSERT} to be sent to the
476+
* registered {@code DocumentListener}s, unless an exception is thrown.
477+
* The {@code DocumentEvent} will be delivered by calling the
478+
* {@code insertUpdate} method on the {@code DocumentListener}.
479+
* The offset and length of the generated {@code DocumentEvent}
480+
* will indicate what change was actually made to the {@code Document}.
481+
* <p>
482+
* For example, if the document contains the text
483+
* <i>&lsquo;The brown fox&rsquo;</i>,
484+
* calling {@code insert(4, "quick ", null)} will insert the word
485+
* <i>&lsquo;quick&rsquo;</i> and the following space into the text,
486+
* and all the marks at 4 and above will be moved by 6 (the number
487+
* of inserted characters).
488+
* <p style="text-align:center"><img src="doc-files/Document-insert.svg"
482489
* alt="Diagram shows insertion of 'quick' in 'The quick brown fox'">
483490
* <p>
484-
* If the Document structure changed as result of the insertion,
485-
* the details of what Elements were inserted and removed in
491+
* If the {@code Document} structure changed as result of the insertion,
492+
* the details of what {@code Element}s were inserted and removed in
486493
* response to the change will also be contained in the generated
487-
* DocumentEvent. It is up to the implementation of a Document
494+
* {@code DocumentEvent}. It is up to the implementation of a {@code Document}
488495
* to decide how the structure should change in response to an
489496
* insertion.
490497
* <p>
491-
* If the Document supports undo/redo, an UndoableEditEvent will
498+
* If the {@code Document} supports undo/redo, an {@code UndoableEditEvent} will
492499
* also be generated.
493500
*
494501
* @param offset the offset into the document to insert the content &gt;= 0.
495502
* All positions that track change at or after the given location
496503
* will move.
497504
* @param str the string to insert
498505
* @param a the attributes to associate with the inserted
499-
* content. This may be null if there are no attributes.
506+
* content. This may be {@code null} if there are no attributes.
500507
* @throws BadLocationException the given insert position is not a valid
501508
* position within the document
502509
* @see javax.swing.event.DocumentEvent
Binary file not shown.
Loading

0 commit comments

Comments
 (0)