void (InputMethodEvent event) { int committedCharacterCount = event.getCommittedCharacterCount(); AttributedCharacterIterator text = event.getText(); if (text == null) { return; } char c = text.first(); if (committedCharacterCount > 0) { StringBuilder textBuffer = new StringBuilder(); while (committedCharacterCount-- > 0) { textBuffer.append(c); c = text.next(); } String committedText = textBuffer.toString(); // Vladimir.Kharitonov@jetbrains.com: // The second argument `replacementRange` is actually not needed. The invalid range shall be passed here. It's not possible because // of https://github.com/chromiumembedded/cef/issues/3422 // To be fixed after updating CEF myBrowser.ImeCommitText(committedText, myRenderHandler.getSelectionRange(), 0); } StringBuilder textBuffer = new StringBuilder(); while (c != CharacterIterator.DONE) { textBuffer.append(c); c = text.next(); } var compositionText = textBuffer.toString(); if (!compositionText.isEmpty()) { CefCompositionUnderline underline = new CefCompositionUnderline(new CefRange(0, compositionText.length()), new Color(0, true), new Color(0, true), 0, CefCompositionUnderline.Style.SOLID); // Vladimir.Kharitonov@jetbrains.com: // The third argument `replacementRange` is actually not needed. The invalid range shall be passed here. It's not possible because // of https://github.com/chromiumembedded/cef/issues/3422 // To be fixed after updating CEF myBrowser.ImeSetComposition(compositionText, List.of(underline), myRenderHandler.getSelectionRange(), new CefRange(compositionText.length(), compositionText.length())); } event.consume(); }