Hi everyone,
I have a huge code of about 4000 lines, which works fine, except for the rendering speed. For this reason, I decided to switch from the default rendering technique to JavaFX 2D. I downloaded the library and imported it:
import processing.javafx.*;
Then modified the size()
in the setup()
:
void setup() {
size(1820,660,FX2D);
frameRate(100);
.
.
.
}
When I run my program, as usual, the following window appears, where I have to write my name, and then press ‘enter’.
However, when I press ‘enter’, I get a very long
NullPointerException
:
NullPointerException
NullPointerException
java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "this.name" is null
at processing.javafx.PGraphicsFX2D$FontCache$Key.hashCode(Unknown Source)
at java.base/java.util.HashMap.hash(HashMap.java:338)
at java.base/java.util.HashMap.getNode(HashMap.java:568)
at java.base/java.util.LinkedHashMap.get(LinkedHashMap.java:441)
at processing.javafx.PGraphicsFX2D$FontCache.get(Unknown Source)
at processing.javafx.PGraphicsFX2D.handleTextFont(Unknown Source)
at processing.javafx.PGraphicsFX2D.textFontImpl(Unknown Source)
at processing.core.PGraphics.textFont(PGraphics.java:4385)
at controlP5.ControlFont.adjust(Unknown Source)
at controlP5.Label$SinglelineLabel.draw(Unknown Source)
at controlP5.Label$SinglelineLabel.draw(Unknown Source)
at controlP5.Label.draw(Unknown Source)
at controlP5.Button$ButtonView.display(Unknown Source)
at controlP5.Button$ButtonView.display(Unknown Source)
at controlP5.Controller.draw(Unknown Source)
at controlP5.ControllerGroup.drawControllers(Unknown Source)
at controlP5.ControllerGroup.draw(Unknown Source)
at controlP5.ControlWindow.draw(Unknown Source)
at controlP5.ControlWindow.draw(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1309)
at processing.core.PApplet.handleMethods(PApplet.java:1456)
at processing.core.PApplet.handleDraw(PApplet.java:2106)
at processing.javafx.PSurfaceFX$1.handle(Unknown Source)
at processing.javafx.PSurfaceFX$1.handle(Unknown Source)
at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:239)
at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:197)
at javafx.graphics/javafx.animation.Timeline.doPlayTo(Timeline.java:172)
at javafx.graphics/javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
at javafx.graphics/com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:120)
at javafx.graphics/javafx.animation.Animation.doTimePulse(Animation.java:1189)
at javafx.graphics/javafx.animation.Animation$1.lambda$timePulse$0(Animation.java:207)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/javafx.animation.Animation$1.timePulse(Animation.java:206)
at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer.timePulseImpl(AbstractPrimaryTimer.java:343)
at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer$MainLoop.run(AbstractPrimaryTimer.java:266)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:571)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:353)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
NullPointerException
When I go back to the default renderer by removing FX2D
from size()
, everything works again…
Does anyone have an idea of what the problem could be?
Thanks in advance!