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

Android studio programming: cannot find BLE device
Random number generator with range in Java
Looking for some good sources to read on creating ArrayLists(in Java) methods from scratch [closed]
JerseyTest NoSuchMethodError
Default Record Reader in Hadoop, global or local byte offset
How would I create a piece of background code using Android Studio
java.text.ParseException: Unparseable date: “04 Mar 2016 20:33+05:30” (at offset 3)
How to remove an imported module in Android Studio
Hibernate retrieving parent/children
In Java, how would I re-initialize the for-loops initialization expression?
Adding multiple items in a Panel At Once
How do I make it so the user has continuous input but can stop this with the use of a symbol?
NullPointerException Java - Where should I create these variables? [duplicate]
How to handle java web start (jnlp) downloading progress in a preloader?
How to Add a collection of elements to my array?
Android in-app billing handling google Server Response Codes

Categories

HOME
pandas
kde
adb
sqlite-net-extensions
dxl
icloud
webpack-2
qore
pheatmap
contact
medical
windows-10-universal
here-api
dax
windows-azure-storage
spring-tool-suite
size
quartz-scheduler
serverless-framework
workload-scheduler
angular-ui
zapier
one-hot-encoding
tokenize
hammerspoon
rundeck
p-value
chromebook
phpfox
webkitspeechrecognition
delicious-api
tinymce-4
fabric8
socialengine
avcapturesession
wixsharp
revolution-slider
service-discovery
core-plot
glew
spring-security-kerberos
s
sas-jmp
galleria
qwt
rainbowtable
dandelion
alphabet
typescript1.8
svmlight
aurelia-validation
colorama
tactic
magma
flow-control
crosswalk-runtime
mediaelement
medium.com
wdf
httplistener
nsfilemanager
master-slave
qgraphicsview
bluegiga
revolution-r
energy
javax.sound.midi
pervasive-sql
qtableview
ora-00900
computer-algebra-systems
coveralls
graph-drawing
apache-commons-fileupload
sniffer
e10s
facebook-graph-api-v2.4
modalpopup
pick
gadt
coldbox
funcunit
mysql-error-1062
mechanize-ruby
coverflow
orchardcms-1.7
sharp-repository
eventlistener
bitsharp
trusted
viewswitcher
assembly-loading
boost-filesystem
fireworks
gwt-ext
doh
vdsp
psi
xmemcached
jquery-ui-droppable
simpletest
pascal-fc
windows-live-messenger





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