Reputation: 17371
I want to create a program in Java with a main window, that can open more subprograms in other windows.
I created a simple JavaFX program for the main window, and it works as expected, like so:
public class MainThread extends Application {
@Override
public void start(Stage primaryStage) {
// code goes here...
}
}
... and I created other Java classes the same way.
I tried to run them simply with new SubProgramThread();
- as I would create a new instance of any object- but that hasn't worked for me- it doesn't run the start()
method in the subprogram classes.
Is that the right way to create an Application
instance?
Thanks.
Upvotes: 0
Views: 1473
Reputation: 1904
I do this all the time. I have a menu of items. When a user clicks the item button I create the new window by calling start() on the FX class:
new TyAltSvr().start(new Stage());
Some people don't like calling start() but it hasn't caused me any problems.
Upvotes: 1