3rd party libraries and Swing on Android

Hi!
I’m working on a project using JME3 and other java technologies. I would like to move my project to Android. However I’m a bit lost.

Is there a way to diffrentiate on what platform I am running so that on desktops I would run Swing UI methods and on Android, Android specific ones?

How can I add additional jars to the project, specific to Android and specific to Java SE, so that different jars are used on different targets?

Thanks for any help :slight_smile:

This is how I differentiate between Android and Desktop

[java]
private static String platform = “”;
private static boolean android = false;

    platform = JmeSystem.getPlatform().toString();
    android = platform.contains("Android");

[/java]

There is a separate project call “mobile” that is the Android project. You can modify it if you want.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:android

2 Likes

As far as i know there is no swing on android?

There is no swing for Android. I think the question is more related to how to detect it is running on Android so an alternative to swing can be used.

Personally, I use only guiNode quads and BitmapText objects so that it will run the same on either Desktop or Android.

@Empire Phoenix said: As far as i know there is no swing on android?

That’s right, hence why he needs to know so he can choose whether to run the swing UI or not…

@iwgeric said: [java] private static String platform = JmeSystem.getPlatform().toString(); [/java]

That solves one of my problems :slight_smile: Thanks a lot!

@iwgeric said: There is a separate project call "mobile" that is the Android project. You can modify it if you want. https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:android

However for the second part… Do you mean that by enabling Android deployment a second set of libraries is attached to the project? If yes, is there a way to hook up into this (apart from modifying the jME Android project)?

@iwgeric said: Personally, I use only guiNode quads and BitmapText objects so that it will run the same on either Desktop or Android.

I use Swing for fatal error handling. If I loose LJWGL context Swing or (AWT) is my last hope, also using a system popup seems more obvious to the user that something went really wrong. That’s also why I’d like to use native Android toolkit in the Android version.

When you enable android a separate android project is created inside your existing one. You can open that as a fully fledged project and modify it if you wish.

@zarch said: When you enable android a separate android project is created inside your existing one. You can open that as a fully fledged project and modify it if you wish.

Is it a full jME library or just some Android specific backends? How does jME know which libs to use? (Ant or some logic in Java or both?)

Its a full netbeans project. Just open it like any other. That project is an android and always android one so picks up the android libs. For the “main” project it looks at the target(deployment/run/whatever you call it) settings to know what libraries to include.

I think I know how to proceed now.

Thanks a lot! :slight_smile: