Menu

#40 AutoSpellCheckHandler Overwrites Attributes

open
nobody
None
5
2009-10-15
2009-10-15
xadhatter
No

When marking words as correct the AutoSpellCheckHandler unnecessarily overwrites attributes This can have bad consequences. For example if the two middle 'e's in the word 'cheese' are marked bold but the rest of the letters are normal when the word is marked as correct, the entire word will become bold. The method AutoSpellCheckHandler.markAsCorrect(...) could be changed to the following:

private void markAsCorrect(StyledDocument doc, int start, int end) {
SimpleAttributeSet attr;
attr = new SimpleAttributeSet();
attr.addAttribute(wordMisspelled, !wordMisspelledTrue);
if (end >= start) {
doc.setCharacterAttributes(start, end - start, attr, false);
}
}

Discussion


Log in to post a comment.