Not able to run two Java FX Instance from Java main application? [duplicate]
This question already has an answer here:
JavaFX launch another application
3 answers
I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.
public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);
BiC class is sample application while I change the text of CxiC class as follow:
public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()
@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");
);
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.
Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
java javafx
marked as duplicate by fabian
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 13 '18 at 22:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
JavaFX launch another application
3 answers
I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.
public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);
BiC class is sample application while I change the text of CxiC class as follow:
public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()
@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");
);
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.
Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
java javafx
marked as duplicate by fabian
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 13 '18 at 22:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
How about creating each instance in a thread ? (one thread for each)
– Chargnn
Nov 13 '18 at 22:18
Application.launch()
blocks until the javafx toolkit shuts down. This is why you don't see the results of the secondlaunch
call immediately. Note that the results of the secondlaunch
call would be an exception, see the duplicate link.
– fabian
Nov 13 '18 at 22:38
All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.
– jewelsea
Nov 14 '18 at 0:28
add a comment |
This question already has an answer here:
JavaFX launch another application
3 answers
I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.
public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);
BiC class is sample application while I change the text of CxiC class as follow:
public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()
@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");
);
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.
Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
java javafx
This question already has an answer here:
JavaFX launch another application
3 answers
I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.
public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);
BiC class is sample application while I change the text of CxiC class as follow:
public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()
@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");
);
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.
Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
This question already has an answer here:
JavaFX launch another application
3 answers
java javafx
java javafx
edited Nov 13 '18 at 22:56
Yatish Bathla
asked Nov 13 '18 at 22:01
Yatish BathlaYatish Bathla
326520
326520
marked as duplicate by fabian
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 13 '18 at 22:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by fabian
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 13 '18 at 22:36
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
How about creating each instance in a thread ? (one thread for each)
– Chargnn
Nov 13 '18 at 22:18
Application.launch()
blocks until the javafx toolkit shuts down. This is why you don't see the results of the secondlaunch
call immediately. Note that the results of the secondlaunch
call would be an exception, see the duplicate link.
– fabian
Nov 13 '18 at 22:38
All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.
– jewelsea
Nov 14 '18 at 0:28
add a comment |
How about creating each instance in a thread ? (one thread for each)
– Chargnn
Nov 13 '18 at 22:18
Application.launch()
blocks until the javafx toolkit shuts down. This is why you don't see the results of the secondlaunch
call immediately. Note that the results of the secondlaunch
call would be an exception, see the duplicate link.
– fabian
Nov 13 '18 at 22:38
All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.
– jewelsea
Nov 14 '18 at 0:28
How about creating each instance in a thread ? (one thread for each)
– Chargnn
Nov 13 '18 at 22:18
How about creating each instance in a thread ? (one thread for each)
– Chargnn
Nov 13 '18 at 22:18
Application.launch()
blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch
call immediately. Note that the results of the second launch
call would be an exception, see the duplicate link.– fabian
Nov 13 '18 at 22:38
Application.launch()
blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch
call immediately. Note that the results of the second launch
call would be an exception, see the duplicate link.– fabian
Nov 13 '18 at 22:38
All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.
– jewelsea
Nov 14 '18 at 0:28
All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.
– jewelsea
Nov 14 '18 at 0:28
add a comment |
1 Answer
1
active
oldest
votes
Calling Application.launch() twice should result in an exception.
From Application.launch() API docs:
Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.
You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Calling Application.launch() twice should result in an exception.
From Application.launch() API docs:
Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.
You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
add a comment |
Calling Application.launch() twice should result in an exception.
From Application.launch() API docs:
Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.
You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
add a comment |
Calling Application.launch() twice should result in an exception.
From Application.launch() API docs:
Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.
You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?
Calling Application.launch() twice should result in an exception.
From Application.launch() API docs:
Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.
You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?
answered Nov 13 '18 at 22:19
B. ThomasB. Thomas
22116
22116
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
add a comment |
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
or even here : stackoverflow.com/a/26369173/4565693
– Chargnn
Nov 13 '18 at 22:21
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.
– Yatish Bathla
Nov 13 '18 at 22:51
add a comment |
How about creating each instance in a thread ? (one thread for each)
– Chargnn
Nov 13 '18 at 22:18
Application.launch()
blocks until the javafx toolkit shuts down. This is why you don't see the results of the secondlaunch
call immediately. Note that the results of the secondlaunch
call would be an exception, see the duplicate link.– fabian
Nov 13 '18 at 22:38
All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.
– jewelsea
Nov 14 '18 at 0:28