java


Trying to launch a new FXML file in javaFX using a method call


I am trying to call another fxml page using a method but getting the error below.
java.lang.IllegalStateException: Not on FX application thread;
currentThread = AWT-EventQueue-0 at
com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:236) at
com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:236) at
com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:423)
at javafx.stage.Stage.(Stage.java:241) at
javafx.stage.Stage.(Stage.java:227) at
thebio.MainController.StudentRegistration(MainController.java:134)
The method below is the one i used in carrying out this event, i don't know where i am getting it wrong please, and any assistance will definitely be well appreciated.
public void StudentRegistration(){
try {
Platform.setImplicitExit(false);
Parent root1;
root1 = FXMLLoader.load(getClass().getResource("Student.fxml"));
Stage stage = new Stage();
stage.setTitle("ABC");
stage.setScene(new Scene(root1));
stage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
Thanks.
Use Platform#runLater to update the GUI from a non-GUI thread.
Platform.runLater(()->{
Parent root1;
root1 = FXMLLoader.load(getClass().getResource("Student.fxml"));
Stage stage = new Stage();
stage.setTitle("ABC");
stage.setScene(new Scene(root1));
stage.show();
});

Related Links

uploading images to server in spring MVC and storing reference in mysql database [closed]
Java - Reading from a file and splitting it into multiple strings
If a String contains a certain letter an exact amount of times
Pause a WatchService WatchKey Java
Android: Perform Small Action When App Leaves Foreground
How can I use a variable for the “expected” attribute of junit #Test?
Analyzing heap dum, Map#size() is not a function?
How to switch (migrate) to Google Cloud SQL from DataStore?
What image processing API should I use for a coloring book [closed]
Game of Life, Calculate neighbors Java
I encrypt data with 32 byte length using AES algorithm the result(cipher text) is 64 byte length,Is this valid?
Receive volume key press events when phone is in deep sleep
velocity template resource not found exception
Accessing properties based on context of WAR (Multiple WARs in single EAR)
Difference in Timestamp in PHP and Java
why does documentUrl return null

Categories

HOME
keycloak
onedrive
routes
kalman-filter
spring-cloud-stream
microservices
ravendb
mouse
autotools
gitpitch
mapserver
alignment
circuit
iron-router
serverless-framework
introduction
orleans
web-sql
claims-based-identity
rundeck
emgucv
smb
xpages-ssjs
buildbot
greendao
libuv
primitive
flink-streaming
google-sites-2016
copying
android-kernel
geopositioning
mpmediaquery
android-ble
ssjs
document.write
bootstrapper
hp-ux
filepicker
pango
domain-model
dropbox-php
nativeapplication
memory-alignment
iso8601
synchronous
ableton-live
merge-conflict-resolution
sigabrt
ubuntu-10.04
packagist
phpcas
google-places
sdhc
metaclass
django-unittest
embedded-code
interrupted-exception
sysinternals
unity5.2.3
nsmutabledictionary
dia
c3
xc16
jscript.net
angularjs-ng-click
bitcoinj
c18
jmapviewer
cos
padarn
plasma
comaddin
unc
bluepill
hosts-file
windows-phone-7.1.1
nsdatecomponents
spyware
table-footer
inotifycollectionchanged
propagation
gdlib
filtered-index
nhibernate.search
vc90
meego
photoshop-cs4
virtual-functions

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App