2

I know that's maybe noob question and lot of others can find it useless, but I would be glad if someone could help me.

In every tutorial I saw making applications in JavaFX static like so:

public class TestingApp extends Application
{

    @Override
    public void start( Stage primaryStage )
    {
        ...
    }

    public static void main( String[] args )
    {
        launch( args );
    }
}

but is there some way to define it non-static like so?:

public class TestingApp extends Application
{

    @Override
    public void start( Stage primaryStage )
    {
        ...
    }

    public TestingApp() {}

}

public class Main
{

    public static void main( String[] args )
    {
        TestingApp ta1 = new TestingApp()
        TestingApp ta2 = new TestingApp()

        ta1.launch( args )
        ta2.launch( args )
    }

}

I already saw this: Starting a second JavaFX Application, but it doesn't solve my problem.

ManoDestra
  • 6,325
  • 6
  • 26
  • 50
  • 2
    What are you trying to achieve through this? – jrtapsell Sep 11 '17 at 19:43
  • It doesn't really make much sense to do this. You should think of `start()` as the entry point of the application - in other words think of it as a replacement for the `main()` method, the only difference being that it is invoked after the FX toolkit has been started and the FX Application Thread is running. Maybe see if https://stackoverflow.com/questions/32464698/java-how-do-i-start-a-standalone-application-from-the-current-one-when-both-are helps. – James_D Sep 11 '17 at 19:52
  • Note that simply stating "it don't solve my problem" is not really going to help get you any answers, since you haven't actually told us what problem you are trying to solve. – James_D Sep 11 '17 at 19:54
  • 1
    Seems to be an [X-Y Problem](http://xyproblem.info/). – ManoDestra Sep 11 '17 at 20:07

1 Answers1

7

Per JVM instance you can only have one JavaFX application and one JavaFX application thread running.

But you can create multiple Stages (windows), if that is what you're looking for. The primary stage is provided by the start method but you can create secondary stages yourself.

Puce
  • 37,247
  • 13
  • 80
  • 152