JavaFX packaged on Android

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size:14px">Making JavaFX executable to the mobile platform has been a community effort.<br>of course, now that JavaFX can be implemented on Android and ios, Let's look at how to package your JavaFX project to the Android Platform.<br>First download the following demo sample: Http://pan.baidu.com/s/1bnwIYrP<br>This demo example is a sample of the official demo sample that I've changed to package a simple JavaFX Program.<br>The demo sample structure is as Follows:</span><br></p></p><p><p><span style="font-size:14px"><br></span></p></p><p>The <p> <span style="font-size:14px">  is visible by the folder Structure. The demo sample was built using the <span style="color: #ff0000">gradle </span>. <span style="color: #ff0000">gradle </span> is also a very hot self-motivated building tool Abroad. <br>   At the time of first packaging. To double-click <span style="color: #ff0000">gradlew.bat </span>, A series of libraries and packages will be downloaded, which may take some time. We need to wait. <br>   Packaging requires <span style="color: #ff0000"> Note </span> The following steps: <br>   <strong> 1. </strong> The project code for JavaFX is placed in the src/main/java/directory below <br>   <strong> 2. </strong> The resources required for JavaFX are placed in the src/main/resources/directory below <br>   <strong> 3. </strong> Change the Build.gradle file, inside the <span style="color: #ff0000">mainclassname </span> represents the package structure of the JavaFX main class. <span style="color: #ff0000">applicationpackage </span> represents the package name of the generated Android APK program, and of course we are able to specify our own xml. This is something that needs to be studied Later. <br>   <strong> 4. </strong> Add the <span style="color: #ff0000">android_home </span> to the environment variable to specify the ANDROIDSDK folder. <br>   After the above operation has been completed. Through cmd into the folder of the demo sample folder, execute <span style="color: #ff0000">gradle run </span> to see if it can be executed, assuming it can be executed. Then execute <span style="color: #ff0000">gradle android </span> to package our apk Program. </span></p></p><p><p><br>The packaged apk is placed below the build/javafxports/android Folder.<br>In addition, there is an important point. According to the official Instructions. The JavaFX program needs to set the stage size by the following code, otherwise there will be a problem with the program resolution and display on the Android Device.<br></p></p><p><p><span style="font-size:14px"></span></p></p><pre name="code" class="java"><pre name="code" class="java">rectangle2d bounds = screen.getprimary (). getvisualbounds (); Scene scene = new scene (root, bounds.getwidth (), bounds.getheight ());</pre></pre>Perform effects such as the following on Android:<p><p></p></p><p><p><span style="font-size:14px"></span></p></p><p><p>Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "width=" height= "640" ><br><br></p></p><p><p><span style="font-size:14px">Click the color, and the following will display the text synchronously. The performance is Good.<br>I have previously written in javafx, the demo sample of SLG can also be packaged on the phone to Execute. There are only individual problems, of course, because there is no adjustment to the resolution of the mobile DEVICE.<br>Interested friends can try it on their own, maybe I will do related research, have the problem can directly comment, there is time I will reply to Answer.</span></p></p><p><p><span style="font-size:14px">--------------------------------------------------------------------------------------------------------------- -------------------------------</span></p></p><p><p><span style="font-size:14px">recently, Twitter and YouTube were much more than a few days of JavaFX packaged on ANDROID. There is no big problem at All. It now supports different operations for each platform and can join Android ADS. Call the Android feature and so On. however, the efficiency of the JavaFX game pack to Android is not optimistic, I wrote a little demo sample packaged on Android.</span></p></p><p><p><span style="font-size:14px"></span></p></p><p><p><span style="font-size:14px"><br></span></p></p><p><p><span style="font-size:14px"></span></p></p><p><p>Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "width=" height= "640" ><br></p></p><p><p><span style="font-size:14px">JavaFX games are generally more efficient on android. I wrote a simple game engine to write some demo samples packaged on android, The object is not very much the case is probably between the 50-60fps. A simple image, added 100 to the same screen, FPS dropped to 20-30. of course, pc and Android performance is very different, the PC has at least 3,000 image,fps to 30 or so (pc test). It's just that, after all, not using OpenGL to do the underlying drawing, it's not too embarrassing to perform efficiently on ANDROID.</span></p></p><p><p><span style="font-size:14px">Let's see if There's any improvement!</span></p></p><p><p></p></p><p><p><span style="font-size:14px">--------------------------------------------------------------------------------------------------------------- ------------------------------</span></p></p><p><p><span style="font-size:14px"><br></span></p></p><p><p><span style="font-size:14px">This article is personal original, reproduced please indicate the source, i csdn blog: http://blog.csdn.net/wingfourever, <span style="font-size:14px">personal blog address: http://www.wjfxgame.com. </span></span></p></p> <p><p>JavaFX packaged on Android</p></p></span>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.