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

Application turns black when dragged from a 4k monitor to a FullHD monitor
Syntax for image button
JOOQ getting an auto generated column value upon inserting it using the record, not returning
AWS API Gateway endpoint works fine in postman, returns 400 Bad Request in Android App
How can I make it so when the user inputs ā€œnā€ times the program will stop?
How to implement a java method to set a user name
Is there a way to prevent web dynos from going to sleep?
How to open each email in gmail?
Error when execute the DFSReadWriteTest.scala using Apache Spark and Scala
Smartcard-io - I get an SCARD_F_COMM_ERROR when listing the connected cards several times
Best approach for designing similar classes while working with JPA and JSF
LDAP Password reset does not respect the pwdhistory attribute
Application was crashing after successful Login through android emulator
How to compile thymeleaf/jsp in java code?
After opening activity i won't replace the layout with fragment but i got exception
Shuffling grouped list with ordering such that element of same group does not appear one after another in java

Categories

HOME
magnific-popup
push-notification
nullpointerexception
fme
tesseract
yahoo-oauth
jsrender
rdf
packages
ckeditor
podio
multiple-records
dacpac
reveal.js
u-sql
resize
timeout
phaser
msp430
lombok
invantive-sql
excel-vba-mac
contextmenu
lucene.net
jquery-ajaxq
h2db
shopware
one-to-many
javacv
semantic-analysis
applozic
dbclient
atlassian-crucible
c++-amp
librato
javascriptcore
ecto
galsim
oracle-fusion-middleware
pdb
calibre
usbserial
optix
ensembles
janrain
botbuilder
btrace
auto-update
togetherjs
mplayer
recursive-datastructures
brightcove
magma
pg-dump
sybase-asa
windows-mobile-6.5
knpmenubundle
pillow
django-scheduler
angular-cache
azure-virtual-network
paypal-express
essence
mutation-observers
spidermonkey
content-length
service-accounts
sysinternals
modalpopup
pick
angularjs-ng-click
mdt
neolane
project-planning
jquery-layout
expected-exception
hippomocks
poller
datagridviewcolumn
uv-mapping
apc
back-stack
android-hardware
tinn-r
typoscript2
trusted
quickdialog
getmessage
wse3.0
code-cleanup
eclipse-templates
libc++
zpt
subgurim-maps
sortable-tables
gamequery
meego
webkit.net
uimenucontroller
phonon
grid-system

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