#weird javafx exception

30 messages · Page 1 of 1 (latest)

hushed gulch
#

So I am making a javafx application and very rarely when I run the application and interact with the UI a bit I would get the exception in the attached file. And not only once, it would throw this exception constantly until I terminated the application. I would give some piece of code but the code is pretty extensive and this exception doesn't really tell me much at all. Does anyone perhaps know what could potentially cause this?

marble wyvernBOT
#

This post has been reserved for your question.

Hey @hushed gulch! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

hushed gulch
#

oh also I am using CSS

#
scene.getStylesheets().add(JFXPlayer.class.getResource("styles.css").toExternalForm());
slider.getStyleClass().add("slider");

 slider.valueProperty().addListener((observable, oldValue, newValue) -> {
                    double bufferPercent =(double) grabberExecutor.getBufferPosition()/(double) grabberExecutor.getLengthInTime()*100.0;
                    double percentage = 100.0 * newValue.doubleValue() / slider.getMax();
                   
                    String style = String.format(
                            

                            "-track-color: linear-gradient(to right, " +
                                    "-fx-accent 0%%, " +
                                    "-fx-accent %1$.1f%%, " +
                                    "gray %1$.1f%%, "+
                                    "gray %2$.1f%%, "+
                                    "-default-track-color %2$.1f%%, " +
                                    "-default-track-color 100%%);"
                                    ,
                            percentage,bufferPercent);



                    slider.setStyle(style);

                 
                });
#

this is basically all the CSS code

#

.slider {
    -default-track-color: -fx-control-inner-background;
    -track-color: white ;
    -fx-transition: -fx-translate-x 1s;
    -fx-accent: red;
    -fx-background-color: transparent;
    -fx-padding: 10px;

}

.slider .thumb {
    -fx-background-color: transparent; /* Or match the track's background color */
    -fx-background-radius: 0; /* Set border radius to 0 to remove any visible border */
    -fx-padding: 0;

}
.slider .track{
    -fx-background-color: -track-color;
}
#

this here is my css file

#

I am suspecting CSS because I feel like this started happening after I added css although I can't say I'm 100% certain, I can't really remember all that well but I think it might be the case

grim lance
#

if you comment out the css is it still happening?

marble wyvernBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

hushed gulch
#

or even less often

#

also sorry for slow response I went to bed shortly after posting

grim lance
#

from what I'm getting from this error you are running a loop somewhere that sometimes goes to -1 for some reason. It's on the main thread so it is probably display logic (unless you've done everything on that main thread which is a big no-no). You'd have to figure out why it's happening and that's your job 60% done.

hushed gulch
#

the main thread? Isn't it the javafx application thread? Or are they basically equivalent in a javafx application

#

also every part of this stack trace is internal to the jdk

#

there's nothing on the stack trace that's my method

grim lance
grim lance
hushed gulch
#

if it was something caused by a method of mine than okay but there is literally nothing on the stack trace that's mine

#

okay I was again doing some stuff and left the program to run and after some time I got this:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "javafx.scene.layout.Background.getFills()" because the return value of "javafx.scene.layout.StackPane.getBackground()" is null
    at javafx.scene.control.skin.SliderSkin.layoutChildren(SliderSkin.java:196)
    at javafx.scene.control.Control.layoutChildren(Control.java:612)
    at javafx.scene.Parent.layout(Parent.java:1208)
    at javafx.scene.Parent.layout(Parent.java:1215)
    at javafx.scene.Scene.doLayoutPass(Scene.java:594)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2596)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:398)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:427)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:592)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:572)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:565)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:352)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
    at java.base/java.lang.Thread.run(Thread.java:1623)
#

a different exception

#

again with no methods on my end ;-;

#

for now I'll open a new issue about using css this way and see if that could potentially cause problems/ if there is a better way

marble wyvernBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

hushed gulch
#

okay. I found out the problem. Turns out when a thread changes the value property of a slider it is the one that also handles the callback of that value property change. I thought it was the javafx application thread that handles all the callbacks for events but apparently not this one. It would have been nice to know god damnit.

#

anyway,thanks

marble wyvernBOT
# hushed gulch anyway,thanks

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.