avoid with NPE when no selection

This commit is contained in:
Ben Fry
2017-10-20 17:19:09 -04:00
parent 6034a0b3d9
commit 49eea9a335
@@ -1580,13 +1580,14 @@ public class JEditTextArea extends JComponent
Clipboard clipboard = getToolkit().getSystemClipboard();
String selection = getSelectedText();
if (selection != null) {
int repeatCount = inputHandler.getRepeatCount();
StringBuilder sb = new StringBuilder();
for(int i = 0; i < repeatCount; i++)
sb.append(selection);
int repeatCount = inputHandler.getRepeatCount();
StringBuilder sb = new StringBuilder();
for(int i = 0; i < repeatCount; i++)
sb.append(selection);
clipboard.setContents(new StringSelection(sb.toString()), null);
clipboard.setContents(new StringSelection(sb.toString()), null);
}
}
}