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

I download an image from the internet with a service. How do i show it?
Java MVC and Action classes
Change a string in one class from another class. Android
hashmap and arraylist connected
Open every link in loop (Selenium)
VisualVM profiler throws null pointer exception for empty main
Change parts of a string
Some javafx classes cannot be resolved in Eclipse using Java SE 8u25
How to deserialize this json
pass jsp parameter to another using button
OpenGL ES 1.0 strange texture behavior
How to add text as a header or footer?
why setting an adapter to a listView doesn't show the list content?
How do I make a variable equal the system time and now keep changing to the system time
Can't put Double number in BigDecimal variable
Java safest way to check client jar server side

Categories

HOME
ms-access
wso2-am
blogger
keycloak
keras
mockito
ngrx
push-notification
dictionary
google-play
google-api-php-client
nullpointerexception
smarty
office365api
programming-languages
baqend
flyway4
session-variables
vault
numeral.js
modelica
circular-dependency
angular-ui
pugjs
pythonanywhere
crystal-reports-2008
devops
autosys
angular2-aot
smb
xpages-ssjs
semantic-analysis
wpfdatagrid
kannel
spring-mybatis
typo3-6.2.x
windowbuilder
vision
instant-messaging
yadcf
google-cloud-endpoints-v2
exuberant-ctags
airconsole
kendo-ui-grid
lxd
wpf-controls
vxworks
disassembling
impersonation
particles.js
dynamic-reports
android-mediaprojection
http-redirect
eventkit
migradoc
slicknav
bonobo
paypal-express
fputcsv
jwplayer7
angstrom-linux
markojs
essence
captivenetwork
ruby-2.2
mutation-observers
sframe
dereference
notify
tween
xcode-6.2
websocket4net
onactivityresult
tld
jquery-layout
jboss-weld
stxxl
coverflow
html4
yui-compressor
simba
dmoz
spring-portlet-mvc
spyware
imac
asp.net-mvc-areas
coda-slider
icanhaz.js
ext3
thunderbird-lightning
firefox4
boost-smart-ptr
phonon

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