0

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?

tpc1095
  • 109
  • 1
  • 12

2 Answers2

2

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.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • The other half of my question is that when I try to debug the desktop it hangs trying to connect a socket to the program, which is not getting launched. – tpc1095 Oct 21 '18 at 13:46
  • Are you telling me Gluon Mobile is not intended for debugging of Macintosh and Windows desktop applications? – tpc1095 Oct 23 '18 at 13:01
  • Gluon Mobile targets mainly mobile devices, but also runs on Desktop. You can debug apps running on desktop or Android. Maybe you can edit your question and make it more clear what is it that you are looking for – José Pereda Oct 23 '18 at 15:22
  • I will try both desktop and mobile. – tpc1095 Oct 23 '18 at 19:36
  • The end of the original question says debugging hangs waiting to connect in port 5005. The app is not started in debug even though it starts with “run”. I wish I could debug. – tpc1095 Oct 23 '18 at 19:38
  • You can debug from IntelliJ, both desktop and Android apps, as in the linked question of my answer. – José Pereda Oct 23 '18 at 20:03
  • What specifically must I do in order to debug the desktop app in Windows? I set a breakpoint in GluonApplication "init()" on "addViewFactory(...") and double-click on ":myApp" -> Tasks -> application -> debug I get this on the console: – tpc1095 Oct 24 '18 at 21:55
  • 5:50:34 PM: Executing task 'debug'... :backpackApp:compileJava UP-TO-DATE :backpackApp:processResources UP-TO-DATE :backpackApp:classes UP-TO-DATE :backpackApp:compileDesktopJava NO-SOURCE :backpackApp:processDesktopResources NO-SOURCE :backpackApp:desktopClasses UP-TO-DATE :backpackApp:debug Listening for transport dt_socket at address: 5005 but the breakpoint is not hit. – tpc1095 Oct 24 '18 at 21:57
0

Solution to part 2: Debug the Desktop version from inside IntelliJ.

In IntelliJ, make a new Run configuration of type Gradle and use "run" not "debug" as the "task". Then choose "backpack [run]" from the toolbar and use the "debug" icon on the toolbar. IntelliJ will run the app with the JDWP options enabled and connect the debugger to it.

tpc1095
  • 109
  • 1
  • 12