< prev index next >

src/java.desktop/share/classes/java/awt/font/TextMeasurer.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -716,10 +716,12 @@
      * the deletion.  Cannot be null.
      * @param deletePos the position in the text where the character was removed.
      * Must not be less than
      * the start of {@code newParagraph}, and must not be greater than the
      * end of {@code newParagraph}.
+     * @throws IllegalArgumentException if multiple characters are deleted from
+     *         the text represented by {@code newParagraph}
      * @throws IndexOutOfBoundsException if {@code deletePos} is
      *         less than the start of {@code newParagraph} or greater
      *         than the end of {@code newParagraph}
      * @throws NullPointerException if {@code newParagraph} is
      *         {@code null}

@@ -727,11 +729,13 @@
     public void deleteChar(AttributedCharacterIterator newParagraph, int deletePos) {
 
         fStart = newParagraph.getBeginIndex();
         int end = newParagraph.getEndIndex();
         if (end - fStart != fChars.length-1) {
-            initAll(newParagraph);
+            // The new paragraph attempts to delete multiple characters
+            throw new IllegalArgumentException("The new paragraph"
+                    + " attempts to delete multiple characters from the text.");
         }
 
         char[] newChars = new char[end-fStart];
         int changedIndex = deletePos-fStart;
 
< prev index next >