Hi Tomas, I changed my code to match the method you gave me before. See code below and the generated error. This is the full stack trace of the error:
The steps are:
Click in text area, apply a font size,.. things work fine..
Then hit Enter.. the error comes up.
I isolated the code that triggers the error, which is this:
public void doTheCaretStyleChange(TextEditorViewPort port, StyleInfo style) {
port.viewPortRichText.plainTextChanges().subscribe(change -> {
int from = change.getPosition();
int length = change.getInserted().length();
port.viewPortRichText.setStyle(from, from + length, style.completeInLineCSS.get());
});
}
-Error----------------------------------------------------------------------------------
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: 11 not in [0, 11)
at org.fxmisc.richtext.Paragraph.subSequence(Paragraph.java:229)
at org.fxmisc.richtext.Paragraph.restyle(Paragraph.java:249)
at org.fxmisc.richtext.EditableStyledDocument.setStyle(EditableStyledDocument.java:200)
at org.fxmisc.richtext.StyledTextArea.setStyle(StyledTextArea.java:477)
at TextComponentElements.TextEditor.lambda$doTheCaretStyleChange$0(TextEditor.java:804)
at TextComponentElements.TextEditor$$Lambda$99/699487773.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/2124890648.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.InterceptableEventStreamImpl$1.consume(InterceptableEventStreamImpl.java:17)
at org.reactfx.PausedConsumer.feedToPrevious(InterceptableEventStreamImpl.java:149)
at org.reactfx.StackedConsumer.unstack(InterceptableEventStreamImpl.java:106)
at org.reactfx.InterceptableEventStreamImpl.unstack(InterceptableEventStreamImpl.java:81)
at org.reactfx.InterceptableEventStreamImpl.lambda$stack$50(InterceptableEventStreamImpl.java:74)
at org.reactfx.InterceptableEventStreamImpl$$Lambda$45/982926558.close(Unknown Source)
at org.reactfx.Hold.lambda$multi$33(Hold.java:23)
at org.reactfx.Hold$$Lambda$47/1800471081.close(Unknown Source)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:563)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:231)
at org.fxmisc.richtext.EditActions.replaceSelection(EditActions.java:144)
at org.fxmisc.richtext.behavior.CodeAreaBehavior.callAction(CodeAreaBehavior.java:213)
at org.fxmisc.richtext.behavior.CodeAreaBehavior.callAction(CodeAreaBehavior.java:140)
at com.sun.javafx.scene.control.behavior.BehaviorBase.callActionForEvent(BehaviorBase.java:222)
at org.fxmisc.richtext.behavior.CodeAreaBehavior.callActionForEvent(CodeAreaBehavior.java:134)
at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(BehaviorBase.java:136)
at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(BehaviorBase.java:133)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene$KeyHandler.process(Scene.java:3949)
at javafx.scene.Scene$KeyHandler.access$2100(Scene.java:3896)
at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2036)
at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2493)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:170)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:123)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:197)
at com.sun.glass.ui.View.handleKeyEvent(View.java:517)
at com.sun.glass.ui.View.notifyKey(View.java:927)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Hi Tomas, I changed my code to match the method you gave me before. See code below and the generated error. This is the full stack trace of the error:
The steps are:
Click in text area, apply a font size,.. things work fine..
Then hit Enter.. the error comes up.
I isolated the code that triggers the error, which is this:
public void doTheCaretStyleChange(TextEditorViewPort port, StyleInfo style) {
port.viewPortRichText.plainTextChanges().subscribe(change -> {
int from = change.getPosition();
int length = change.getInserted().length();
port.viewPortRichText.setStyle(from, from + length, style.completeInLineCSS.get());
});
}
-Error----------------------------------------------------------------------------------
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: 11 not in [0, 11)
at org.fxmisc.richtext.Paragraph.subSequence(Paragraph.java:229)
at org.fxmisc.richtext.Paragraph.restyle(Paragraph.java:249)
at org.fxmisc.richtext.EditableStyledDocument.setStyle(EditableStyledDocument.java:200)
at org.fxmisc.richtext.StyledTextArea.setStyle(StyledTextArea.java:477)
at TextComponentElements.TextEditor.lambda$doTheCaretStyleChange$0(TextEditor.java:804)
at TextComponentElements.TextEditor$$Lambda$99/699487773.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/2124890648.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.InterceptableEventStreamImpl$1.consume(InterceptableEventStreamImpl.java:17)
at org.reactfx.PausedConsumer.feedToPrevious(InterceptableEventStreamImpl.java:149)
at org.reactfx.StackedConsumer.unstack(InterceptableEventStreamImpl.java:106)
at org.reactfx.InterceptableEventStreamImpl.unstack(InterceptableEventStreamImpl.java:81)
at org.reactfx.InterceptableEventStreamImpl.lambda$stack$50(InterceptableEventStreamImpl.java:74)
at org.reactfx.InterceptableEventStreamImpl$$Lambda$45/982926558.close(Unknown Source)
at org.reactfx.Hold.lambda$multi$33(Hold.java:23)
at org.reactfx.Hold$$Lambda$47/1800471081.close(Unknown Source)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:563)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:231)
at org.fxmisc.richtext.EditActions.replaceSelection(EditActions.java:144)
at org.fxmisc.richtext.behavior.CodeAreaBehavior.callAction(CodeAreaBehavior.java:213)
at org.fxmisc.richtext.behavior.CodeAreaBehavior.callAction(CodeAreaBehavior.java:140)
at com.sun.javafx.scene.control.behavior.BehaviorBase.callActionForEvent(BehaviorBase.java:222)
at org.fxmisc.richtext.behavior.CodeAreaBehavior.callActionForEvent(CodeAreaBehavior.java:134)
at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(BehaviorBase.java:136)
at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(BehaviorBase.java:133)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene$KeyHandler.process(Scene.java:3949)
at javafx.scene.Scene$KeyHandler.access$2100(Scene.java:3896)
at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2036)
at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2493)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:170)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:123)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:197)
at com.sun.glass.ui.View.handleKeyEvent(View.java:517)
at com.sun.glass.ui.View.notifyKey(View.java:927)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)