Hello,
I'm currently working on a project that executes maven commands. In this project, I retrieve the output of a Process instance and I would like to display that output in real time using a TextArea. The problem is that when I append too much text (at least I guess so), I get a NullPointerException and I don't know how to solve that problem. Lets look at the code I have:
// Somewhere
@FXML TextArea consoleOutput;
// Somewhere else
final ChangeListener<String> repositoryExecutionStackChangeListener = new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observableValue, String s, String s2) {
String stringToAppend = null;
if(s == null) stringToAppend = s2;
else if(s2 != null) stringToAppend = s2.substring(0, s.length());
if(stringToAppend != null) {
consoleOutput.appendText(stringToAppend);
consoleOutput.setScrollTop(Double.MIN_VALUE);
}
}
The listener is added correctly and trust me, the consoleOuput displays the result until I get this exception:
java.lang.NullPointerException
at com.sun.javafx.sg.prism.NGTextHelper$TextAttributes.computeLinePadding(NGTextHelper.java:389)
at com.sun.javafx.sg.prism.NGTextHelper$TextAttributes.access$200(NGTextHelper.java:292)
at com.sun.javafx.sg.prism.NGTextHelper.buildTextLines(NGTextHelper.java:2357)
at com.sun.javafx.sg.prism.NGTextHelper.validateText(NGTextHelper.java:1847)
at com.sun.javafx.sg.prism.NGTextHelper.getCaretShape(NGTextHelper.java:1435)
at javafx.scene.text.Text.getDecorationShapes(Text.java:1150)
at javafx.scene.text.Text.access$2100(Text.java:110)
at javafx.scene.text.Text$14.invalidated(Text.java:1027)
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:129)
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:163)
at javafx.scene.text.Text.setImpl_caretPosition(Text.java:1002)
at com.sun.javafx.scene.control.skin.TextAreaSkin$ContentView.layoutChildren(TextAreaSkin.java:295)
at javafx.scene.Parent.layout(Parent.java:1018)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Scene.layoutDirtyRoots(Scene.java:516)
at javafx.scene.Scene.doLayoutPass(Scene.java:487)
at javafx.scene.Scene.access$3900(Scene.java:170)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2186)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:463)
at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:332)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
I don't know how to solve this. Any ideas? Thank you very much.
PS: Environment: OSX Maverick, JDK7u45