intellij-ideajavafxgluon-mobilejdwpgluon-desktop

Newbie cannot properly run or debug fresh project using Gluon multi-view with FXML in IntelliJ


I created a brand new Gluon mobile multi view with FXML project in IntelliJ CE 2018.2.1 using the Gluon plugin version 2.7.0 and Gradle 4.10.1

I open the Gradle tool window, Pick Project(root), Tasks, Application, run and I do see the generated application run properly, I believe, though it defaults to a mobile device sized window.

I get this error message:

SEVERE: javafx.platform is not defined. Desktop will be assumed by default.

What I'd like to do is debug a single JavaFX program in IntelliJ for all of the supported platforms (except embedded) in Windows and see more or less the right screen sizes before I start plugging in my iPad/iPhone/Android phone/Android tablet/Mac just to get the code logic right.

Is there some setting that would let me switch between simulating different devices as a first stage?

When I double click "debug" I get the following message and the window hangs.

Listening for transport dt_socket at address: 5005

Is this related? Are we trying to debug an actual device by accident?


Solution

  • As for the app size, when you run on desktop it defaults to a phone form factor of 335x600. This comes from the Display service:

    @Override
    public Dimension2D getDefaultDimensions() {
        return isTablet() ? new Dimension2D(900, 600) : new Dimension2D(335, 600);
    }
    

    You can change to a tablet format of 900 x 600 if you set the charm-desktop-form system property to tablet.

    Or you can simply override these settings, and set your desired size:

    @Override
    public void postInit(Scene scene) {
        Swatch.BLUE.assignTo(scene);
    
        if (Platform.isDesktop()) {
            ((Stage) scene.getWindow()).setWidth(400);
            ((Stage) scene.getWindow()).setHeight(800);
        }
    }
    

    When you deploy your app to a mobile device, it will just adjust to the size of its screen.

    Related to the message javafx.platform is not defined running on desktop, that system property is not defined, so it is a warning message that informs that desktop is selected. When you run on mobile, the proper Android or iOS value will be set for the platform.

    Finally, about debugging, when you run on desktop you initially can debug only the desktop application, but you can modify the size of the application as mentioned above.

    To debug the mobile application, you have to run either the iOS simulator or the Android emulator.

    This question shows how to debug on Android from IntelliJ, but you have to actually deploy the application to a mobile device.

    On iOS, providing you have a Mac, you can use the launchIPhoneSimulator task to launch the iOS simulator, where you can choose any of the possible iPhone or iPad devices with their different screens resolutions. In this case you don't need a device.