|
1 | 1 | /*
|
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -471,32 +471,39 @@ public interface Document {
|
471 | 471 | public void remove(int offs, int len) throws BadLocationException;
|
472 | 472 |
|
473 | 473 | /**
|
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>‘The brown fox’</i>, |
| 484 | + * calling {@code insert(4, "quick ", null)} will insert the word |
| 485 | + * <i>‘quick’</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" |
482 | 489 | * alt="Diagram shows insertion of 'quick' in 'The quick brown fox'">
|
483 | 490 | * <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 |
486 | 493 | * 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} |
488 | 495 | * to decide how the structure should change in response to an
|
489 | 496 | * insertion.
|
490 | 497 | * <p>
|
491 |
| - * If the Document supports undo/redo, an UndoableEditEvent will |
| 498 | + * If the {@code Document} supports undo/redo, an {@code UndoableEditEvent} will |
492 | 499 | * also be generated.
|
493 | 500 | *
|
494 | 501 | * @param offset the offset into the document to insert the content >= 0.
|
495 | 502 | * All positions that track change at or after the given location
|
496 | 503 | * will move.
|
497 | 504 | * @param str the string to insert
|
498 | 505 | * @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. |
500 | 507 | * @throws BadLocationException the given insert position is not a valid
|
501 | 508 | * position within the document
|
502 | 509 | * @see javax.swing.event.DocumentEvent
|
|
0 commit comments