0

I have two classes : One is called "Game" and it extends Application. Running this will launch the video game I've created. The other is called LocalClient, it also extends Application. Running this will give me a Menu, giving me the option to open the game by the press of a button. The problem is that I don't want to open the game, I just want to render both Applications in the same Frame

public class LocalClient extends Application {

    Pane root;

    @Override
    public void start(Stage primaryStage) throws Exception {
// my start method for LocalClient
}

private class GameMenu extends Parent {
// this is another class where i have my buttons and the different menus/submenus
}


public class Game extends Application {

    private Pane root = new Pane();
    private Level level; // level is an abstract class I use

    /**
     * Stars the game and begins rendering
     * @param stage stage to render all objects to
     */
    @Override
    public void start(Stage stage) {
// my Start mmethod for the game

user11251276
  • 53
  • 1
  • 8
  • This seems like very strange design. Why not have just one application that runs both the client and the game? – Zephyr Mar 24 '19 at 16:58
  • I am working with a team and we got to different aspects of the project separately. The game works, however we'd like to make it look more united – user11251276 Mar 24 '19 at 17:01
  • I don't believe there is a way to run one JavaFX application within the window of another. But something like this should definitely be just one application. Whatever UI was designed for the game portion could easily be placed within a pane in the main Client application window... – Zephyr Mar 24 '19 at 17:03
  • Not sure if this is 100% a duplicate, but an approach is presented in the accepted answer here: https://stackoverflow.com/questions/15653118/javafx-launch-another-application – fabian Mar 24 '19 at 18:27
  • Thank you for your help, however, I am already able to launch an application from within another. What I want to do is to possibly "combine" them – user11251276 Mar 24 '19 at 20:31

1 Answers1

0

Inside your main(String[] args) method, instead of using launch(args);, you can use Game.launch(args);. Then, inside the start() method in your Game class, type LocalClient.launch(args);.

Superhuman
  • 85
  • 9